: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(desktop): let the spaces layout hide and reorder sidebar nav items (#86583)
Thomas Obermüllere35e4e1127e1
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.test.tsxindex 95ced96dde07..ac9ca806104a 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.test.tsx@@ -26,6 +26,7 @@ vi.mock("@posthog/ui/router/navigationBridge", () => ({navigateToActivity: vi.fn(),navigateToHome: vi.fn(),navigateToInbox: vi.fn(),+ navigateToLoops: vi.fn(),navigateToWebsiteCommandCenter: vi.fn(),}));vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));@@ -33,11 +34,47 @@ vi.mock("./ActivityHoverCard", () => ({ActivityHoverCard: () => <div>Recent activity card</div>,}));+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";import { ChannelNav } from "./ChannelNav";+const navLabels = (container: HTMLElement) =>+ [...container.querySelectorAll("button")].map((button) =>+ button.getAttribute("aria-label"),+ );+describe("ChannelNav", () => {beforeEach(() => {mocks.view = { type: "task-input" };+ useSidebarStore.setState({ navItemOverrides: {}, navItemOrder: [] });+ });++ it("keeps Inbox available in the channels navigation", () => {+ render(<ChannelNav />);++ expect(screen.getByLabelText("Inbox")).toBeEnabled();+ });++ it("drops an item hidden in the sidebar settings", () => {+ useSidebarStore.setState({ navItemOverrides: { "command-center": false } });++ render(<ChannelNav />);++ expect(screen.queryByLabelText("Command Center")).not.toBeInTheDocument();+ expect(screen.getByLabelText("Inbox")).toBeInTheDocument();+ });++ it("follows the order stored by the sidebar settings, after Home", () => {+ useSidebarStore.setState({ navItemOrder: ["configure", "inbox"] });++ const { container } = render(<ChannelNav />);++ expect(navLabels(container)).toEqual([+ "Home",+ "Settings",+ "Inbox",+ "Activity",+ "Command Center",+ ]);});it("opens recent activity from the bell after the hover delay", async () => {diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.tsxindex dcf9d3f28468..76f55b9463df 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelNav.tsx@@ -30,6 +30,12 @@ import { useCommandCenterActiveCount } from "@posthog/ui/features/command-centerimport { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAllReports";import { openSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";+import {+ type CustomizableNavItemId,+ isNavItemVisible,+ orderedNavItems,+} from "@posthog/ui/features/sidebar/constants";+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";import { CountBadge } from "@posthog/ui/primitives/CountBadge";import { LoopIcon } from "@posthog/ui/primitives/LoopIcon";import {@@ -43,6 +49,7 @@ import { useAppView } from "@posthog/ui/router/useAppView";import { track } from "@posthog/ui/shell/analytics";import {type ComponentPropsWithRef,+ Fragment,type ReactElement,type ReactNode,useState,@@ -192,6 +199,8 @@ export function ChannelNav() {});const { unreadCount: unseenActivity } = useTaskActivity();const commandCenterCount = useCommandCenterActiveCount();+ const navItemOverrides = useSidebarStore((s) => s.navItemOverrides);+ const navItemOrder = useSidebarStore((s) => s.navItemOrder);const withTrack = (item: SidebarNavItem, action: () => void) => () => {track(ANALYTICS_EVENTS.SIDEBAR_NAV_ITEM_CLICKED, {@@ -206,6 +215,76 @@ export function ChannelNav() {const isInbox = view.type === "inbox";const isActivity = view.type === "activity";const isCommandCenter = view.type === "command-center";+ const isLoops = view.type === "loops";++ // Bluebird is already on wherever this nav renders, so Activity needs no+ // second gate here — unlike the code layout's SidebarNavSection.+ const navItemAvailable: Record<CustomizableNavItemId, boolean> = {+ inbox: true,+ activity: true,+ "command-center": true,+ loops: loopsEnabled,+ configure: true,+ };++ const renderNavItem: Record<CustomizableNavItemId, () => ReactNode> = {+ inbox: () => (+ <NavIcon+ icon={+ <EnvelopeSimple size={16} weight={isInbox ? "fill" : "regular"} />+ }+ label="Inbox"+ shortcut={formatHotkey(SHORTCUTS.INBOX)}+ isActive={isInbox}+ onClick={withTrack("inbox", navigateToInbox)}+ badge={<CountBadge count={counts.pulls} className={ICON_BADGE_CLASS} />}+ />+ ),+ activity: () => (+ <ActivityNavItem+ isActive={isActivity}+ unreadCount={unseenActivity}+ onNavigate={withTrack("activity", navigateToActivity)}+ />+ ),+ "command-center": () => (+ <NavIcon+ icon={+ <Lightning size={16} weight={isCommandCenter ? "fill" : "regular"} />+ }+ label="Command Center"+ isActive={isCommandCenter}+ onClick={withTrack("command_center", navigateToWebsiteCommandCenter)}+ badge={+ <CountBadge+ count={commandCenterCount}+ tone="neutral"+ className={ICON_BADGE_CLASS}+ />+ }+ />+ ),+ loops: () => (+ <NavIcon+ icon={<LoopIcon size={16} weight={isLoops ? "fill" : "regular"} />}+ label="Loops"+ isActive={isLoops}+ onClick={withTrack("loops", navigateToLoops)}+ />+ ),+ configure: () => (+ <NavIcon+ icon={<GearSix size={16} />}+ label="Settings"+ isActive={false}+ onClick={withTrack("configure", () => openSettings())}+ />+ ),+ };++ const items = orderedNavItems(navItemOrder).filter(+ ({ id }) => navItemAvailable[id] && isNavItemVisible(navItemOverrides, id),+ );return (// One provider for the row: once any tooltip is up, moving to its@@ -215,66 +294,17 @@ export function ChannelNav() {// providers never share it.<TooltipProvider delay={400}><div className="flex shrink-0 gap-2 p-2">+ {/* Home is the space's own root rather than one of the customizable+ destinations, so it stays first and is never hidden. */}<NavIconicon={<HouseSimple size={16} weight={isHome ? "fill" : "regular"} />}label="Home"isActive={isHome}onClick={withTrack("home", navigateToHome)}/>- <NavIcon- icon={- <EnvelopeSimple size={16} weight={isInbox ? "fill" : "regular"} />- }- label="Inbox"- shortcut={formatHotkey(SHORTCUTS.INBOX)}- isActive={isInbox}- onClick={withTrack("inbox", navigateToInbox)}- badge={- <CountBadge count={counts.pulls} className={ICON_BADGE_CLASS} />- }- />- <ActivityNavItem- isActive={isActivity}- unreadCount={unseenActivity}- onNavigate={withTrack("activity", navigateToActivity)}- />- <NavIcon- icon={- <Lightning- size={16}- weight={isCommandCenter ? "fill" : "regular"}- />- }- label="Command Center"- isActive={isCommandCenter}- onClick={withTrack("command_center", navigateToWebsiteCommandCenter)}- badge={- <CountBadge- count={commandCenterCount}- tone="neutral"- className={ICON_BADGE_CLASS}- />- }- />- {loopsEnabled ? (- <NavIcon- icon={- <LoopIcon- size={16}- weight={view.type === "loops" ? "fill" : "regular"}- />- }- label="Loops"- isActive={view.type === "loops"}- onClick={withTrack("loops", navigateToLoops)}- />- ) : null}- <NavIcon- icon={<GearSix size={16} />}- label="Settings"- isActive={false}- onClick={withTrack("configure", () => openSettings())}- />+ {items.map(({ id }) => (+ <Fragment key={id}>{renderNavItem[id]()}</Fragment>+ ))}</div></TooltipProvider>);diff --git a/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx b/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsxindex 323cfbb67019..648dc3078571 100644--- a/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx+++ b/products/desktop/packages/ui/src/features/settings/components/SettingsPanel.tsx@@ -31,7 +31,6 @@ import { useAuthStateValue } from "@posthog/ui/features/auth/store";import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";import { useLogoutMutation } from "@posthog/ui/features/auth/useAuthMutations";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";-import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";import { useQuickAskAvailable } from "@posthog/ui/features/quick-ask/useQuickAskAvailable";import { SettingsPageContent } from "@posthog/ui/features/settings/components/SettingsPageContent";@@ -148,8 +147,6 @@ export function SettingsPanel({const client = useOptionalAuthenticatedClient();const { data: user } = useCurrentUser({ client });const billingEnabled = useFeatureFlag(BILLING_FLAG);- // The channels layout's nav is fixed, so the Sidebar page can't do anything.- const channelsLayout = useChannelsLayout();const { localWorkspaces } = useHostCapabilities();const logoutMutation = useLogoutMutation();const quickAskAvailable = useQuickAskAvailable();@@ -159,7 +156,6 @@ export function SettingsPanel({billingEnabled,spendAnalysisEnabled,localWorkspaces,- channelsLayout,quickAskAvailable,});const sidebarGroups = SIDEBAR_GROUPS.map((group) => ({diff --git a/products/desktop/packages/ui/src/features/settings/settingsVisibility.test.ts b/products/desktop/packages/ui/src/features/settings/settingsVisibility.test.tsindex 375715f72603..1567d70c73fa 100644--- a/products/desktop/packages/ui/src/features/settings/settingsVisibility.test.ts+++ b/products/desktop/packages/ui/src/features/settings/settingsVisibility.test.ts@@ -33,19 +33,6 @@ describe("getHiddenSettingsCategories", () => {},expected: ["workspaces", "worktrees", "terminal", "harness", "discord"],},- {- // The channels layout uses a fixed nav, so the Sidebar page's- // reorder/hide controls would have nothing to act on.- name: "hides the sidebar page under the channels layout",- input: {- billingEnabled: true,- spendAnalysisEnabled: true,- localWorkspaces: true,- channelsLayout: true,- quickAskAvailable: true,- },- expected: ["sidebar"],- },{// The page's only content when the panel is unavailable is a dead-end// "not available in this build" message, so hide it (web hosts anddiff --git a/products/desktop/packages/ui/src/features/settings/settingsVisibility.ts b/products/desktop/packages/ui/src/features/settings/settingsVisibility.tsindex e2b78753603f..c4166eac9d3e 100644--- a/products/desktop/packages/ui/src/features/settings/settingsVisibility.ts+++ b/products/desktop/packages/ui/src/features/settings/settingsVisibility.ts@@ -15,11 +15,6 @@ interface SettingsVisibility {billingEnabled: boolean;spendAnalysisEnabled: boolean;localWorkspaces: boolean;- /**- * The channels layout replaces the customizable nav with a fixed one, so the- * Sidebar page's controls have nothing to act on there.- */- channelsLayout?: boolean;/*** The quick-ask panel exists on this host and build. Off (web, and packaged* desktop without the prototype gate) hides its settings page, whose only@@ -32,9 +27,10 @@ export function getHiddenSettingsCategories({billingEnabled,spendAnalysisEnabled,localWorkspaces,- channelsLayout = false,quickAskAvailable = false,}: SettingsVisibility): ReadonlySet<SettingsCategory> {+ // SettingsPanel drops these from its nav and its search, and redirects+ // direct navigation to one, so a deep link can't reach them either.const hiddenCategories = new Set<SettingsCategory>();if (!billingEnabled && !spendAnalysisEnabled) {@@ -45,12 +41,6 @@ export function getHiddenSettingsCategories({hiddenCategories.add(category);}}- // Better to hide the page than to leave one whose controls silently do- // nothing. SettingsPanel also redirects direct navigation to a hidden- // category, so a deep link can't reach it either.- if (channelsLayout) {- hiddenCategories.add("sidebar");- }if (!quickAskAvailable) {hiddenCategories.add("quick-ask");}