: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
perf(frontend): keep the today rail items out of the logged-in shell (#122617)
Paul D'Ambra19fcd32ea03f
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjsindex 4bbf4639b5f7..63dfa01ee22a 100644--- a/frontend/bin/check-eager-graph.mjs+++ b/frontend/bin/check-eager-graph.mjs@@ -122,6 +122,8 @@ const ROOTS = ['src/layout/today/TodayContextPanelFloating.tsx','src/layout/today/TodaySidePanel.tsx','src/layout/today/TodayTopBar.tsx',+ // The rail's pane actions pull in the new-analytics menu and the canvas block library.+ 'src/layout/today/todayRailItems.tsx',// The zod-en-locale-only plugin in common/esbuilder/utils.mjs keeps every locale except// `en` out of the build. A hit on another locale means zod moved its locales barrel and// the plugin no longer matches it.diff --git a/frontend/src/layout/today/TodayNewChatButton.tsx b/frontend/src/layout/today/TodayNewChatButton.tsxindex 7c08d213565b..5bb67d2c0f30 100644--- a/frontend/src/layout/today/TodayNewChatButton.tsx+++ b/frontend/src/layout/today/TodayNewChatButton.tsx@@ -7,7 +7,7 @@ import { Button, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quimport { LinkPrimitive } from 'lib/lemon-ui/Link'import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'-import { todayNewChatUrl } from './todayRailItems'+import { todayNewChatUrl } from './todayShellLogic'export function TodayNewChatButton(): JSX.Element {const { location, searchParams } = useValues(router)diff --git a/frontend/src/layout/today/todayRailItems.tsx b/frontend/src/layout/today/todayRailItems.tsxindex bae884b7ba03..a8a258c2ae8b 100644--- a/frontend/src/layout/today/todayRailItems.tsx+++ b/frontend/src/layout/today/todayRailItems.tsx@@ -2,8 +2,6 @@ import { IconApps, IconChat, IconGear, IconHome, IconSidebarClose, IconSidebarOpimport { IconAnalyticsBars } from 'lib/lemon-ui/icons'import { isMac } from 'lib/utils/dom'-import type { PhaiViewMode } from 'scenes/max/maxGlobalLogic'-import { urls } from 'scenes/urls'import { TodayNewAnalyticsButton } from './TodayNewAnalyticsButton'import { TodayNewChatButton } from './TodayNewChatButton'@@ -14,34 +12,20 @@ export interface TodayPane {/** The title on top of the pane. The scene header shows it too while the sidebar is hidden. */title: stringicon: JSX.Element- /** The page a rail pick opens. Without one, a pick only opens the sidebar and the open page stays. */- home?: (effectivePhaiView: PhaiViewMode) => stringaction?: () => JSX.Element}-/** The task composer runs on the sandbox, so the legacy view starts a chat on `/ai` instead. */-export function todayNewChatUrl(effectivePhaiView: PhaiViewMode): string {- return effectivePhaiView === 'new' ? urls.taskNewSession() : urls.ai()-}-export const TODAY_PANES: Record<TodayRailPane, TodayPane> = {- home: { label: 'Home', title: 'Today', icon: <IconHome />, home: () => urls.projectHomepage() },+ home: { label: 'Home', title: 'Today', icon: <IconHome /> },spaces: {label: 'Chats',title: 'Chats',icon: <IconChat />,- home: todayNewChatUrl,action: TodayNewChatButton,},- analytics: {- label: 'Analytics',- title: 'Analytics',- icon: <IconAnalyticsBars />,- home: () => urls.analyticsProductHome(),- action: TodayNewAnalyticsButton,- },+ analytics: { label: 'Analytics', title: 'Analytics', icon: <IconAnalyticsBars />, action: TodayNewAnalyticsButton },products: { label: 'Products', title: 'Products', icon: <IconApps /> },- settings: { label: 'Settings', title: 'Settings', icon: <IconGear />, home: () => urls.settings('project') },+ settings: { label: 'Settings', title: 'Settings', icon: <IconGear /> },}export const TODAY_RAIL_PANES: TodayRailPane[] = ['home', 'spaces', 'analytics', 'products']diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.tsindex 4244fefd7463..90762c6f69ca 100644--- a/frontend/src/layout/today/todayShellLogic.test.ts+++ b/frontend/src/layout/today/todayShellLogic.test.ts@@ -4,11 +4,18 @@ import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { getToolSourceItems, isToolItem, toolLabel } from 'scenes/tools/toolsUtils'+import { urls } from 'scenes/urls'import { navProductHrefForPath } from '~/layout/panel-layout/navbar/tabs/navProductItems'import { initKeaTests } from '~/test/init'-import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_MAX_WIDTH, railPaneForPath, todayShellLogic } from './todayShellLogic'+import {+ TODAY_RAIL_WIDTH,+ TODAY_SIDEBAR_MAX_WIDTH,+ railPaneForPath,+ railPaneHref,+ todayShellLogic,+} from './todayShellLogic'describe('todayShellLogic', () => {beforeEach(() => {@@ -111,6 +118,17 @@ describe('todayShellLogic', () => {expect(logic.values.activePane).toBe(pane)})+ test.each([+ ['home', 'new', urls.projectHomepage()],+ ['spaces', 'new', urls.taskNewSession()],+ ['spaces', 'legacy', urls.ai()],+ ['analytics', 'new', urls.analyticsProductHome()],+ ['products', 'new', undefined],+ ['settings', 'new', urls.settings('project')],+ ] as const)('a rail pick on %s with the %s PostHog AI view opens %s', (pane, phaiView, href) => {+ expect(railPaneHref(pane, phaiView)).toBe(href)+ })+test.each(['spaces', 'analytics', 'products'] as const)('a second rail click on %s hides the sidebar it opened',(pane) => {diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.tsindex a9634b98c14c..bbaa5cfecb52 100644--- a/frontend/src/layout/today/todayShellLogic.ts+++ b/frontend/src/layout/today/todayShellLogic.ts@@ -18,8 +18,6 @@ import { navigationLogic } from '~/layout/navigation/navigationLogic'import { getNavProductPages, navProductHrefForPath } from '~/layout/panel-layout/navbar/tabs/navProductItems'import { FileSystemImport } from '~/queries/schema/schema-general'-import { TODAY_PANES } from './todayRailItems'-export type TodayRailPane = 'home' | 'spaces' | 'analytics' | 'products' | 'settings'/** What showed or hid the sidebar. `navigation` is a page change that hides the unpinned sidebar. */@@ -46,9 +44,22 @@ export function clampSidebarWidth(width: number | null): number {)}+/** The task composer runs on the sandbox, so the legacy view starts a chat on `/ai` instead. */+export function todayNewChatUrl(effectivePhaiView: PhaiViewMode): string {+ return effectivePhaiView === 'new' ? urls.taskNewSession() : urls.ai()+}++/** The page a rail pick opens. Without one, a pick only opens the sidebar and the open page stays. */+const RAIL_PANE_HOMES: Partial<Record<TodayRailPane, (effectivePhaiView: PhaiViewMode) => string>> = {+ home: () => urls.projectHomepage(),+ spaces: todayNewChatUrl,+ analytics: () => urls.analyticsProductHome(),+ settings: () => urls.settings('project'),+}+/** The page a rail pane opens, or undefined when the pane only opens the sidebar. */export function railPaneHref(pane: TodayRailPane, effectivePhaiView: PhaiViewMode): string | undefined {- return TODAY_PANES[pane].home?.(effectivePhaiView)+ return RAIL_PANE_HOMES[pane]?.(effectivePhaiView)}const PHONE_PAGE_LIMIT = 50