: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(today): hide project-tree file items in the today layout (#116199)
Adam Leithc2f59316ea0c
diff --git a/.agents/skills/scene-menu-bar/SKILL.md b/.agents/skills/scene-menu-bar/SKILL.mdindex de6f61a6c092..04805c3e2bc7 100644--- a/.agents/skills/scene-menu-bar/SKILL.md+++ b/.agents/skills/scene-menu-bar/SKILL.md@@ -80,14 +80,14 @@ visible (greyed out, `cursor-not-allowed`) so the menu set still communicates thcapabilities to the user.For menus whose children may render null at runtime (the most common case is-`<SceneMenuBarFileItems>`, which returns null when no project-tree entry is registered),+`<SceneMenuBarFileItems>`, which returns null when `sceneFileLogic.hasFileItems` is false: no project-tree+entry is registered, or the Today layout is on),the parent **cannot detect** that the popup will be empty. You must either:1. **Pass `disabled` explicitly** based on the same value the children depend on, e.g.:```tsx- const { projectTreeRefEntry } = useValues(projectTreeDataLogic)- const hasFileItems = !!projectTreeRefEntry+ const { hasFileItems } = useValues(sceneFileLogic)<SceneMenuBarMenu label="File" disabled={!hasFileItems}>{hasFileItems && <SceneMenuBarFileItems dataAttrKey="…" />}</SceneMenuBarMenu>@@ -133,7 +133,7 @@ See `saveTagsInline` in `frontend/src/scenes/feature-flags/featureFlagLogic.ts`.Use `<SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />` at the bottom of File(before the destructive separator) to render Open in project tree, Move to folder,-Add/Remove starred. It auto-hides when no project-tree entry is registered.+Add/Remove starred. It auto-hides when `sceneFileLogic.hasFileItems` is false.### Right clusterdiff --git a/frontend/src/lib/components/Scenes/SceneMenuBarFileItems.tsx b/frontend/src/lib/components/Scenes/SceneMenuBarFileItems.tsxindex 9369f2c9f8f5..84111a36a5eb 100644--- a/frontend/src/lib/components/Scenes/SceneMenuBarFileItems.tsx+++ b/frontend/src/lib/components/Scenes/SceneMenuBarFileItems.tsx@@ -1,4 +1,4 @@-import { useActions, useMountedLogic, useValues } from 'kea'+import { useActions, useValues } from 'kea'import { IconFolderMove, IconFolderOpen, IconStar, IconStarFilled } from '@posthog/icons'@@ -19,16 +19,15 @@ type SceneMenuBarFileItemsProps = {/*** File-system actions for the current scene's tree entry, intended to be placed inside- * a <SceneMenuBarMenu label="File">. Returns null if no project tree entry is registered.+ * a <SceneMenuBarMenu label="File">. Returns null when `sceneFileLogic.hasFileItems` is false, so parents gate on it.*/export function SceneMenuBarFileItems({ dataAttrKey }: SceneMenuBarFileItemsProps): JSX.Element | null {- useMountedLogic(sceneFileLogic)+ const { fileItemsEntry: projectTreeRefEntry } = useValues(sceneFileLogic)const { assureVisibility } = useActions(projectTreeLogic({ key: PROJECT_TREE_KEY }))const { showLayoutPanel, setActivePanelIdentifier } = useActions(panelLayoutLogic)const { addShortcutItem, deleteShortcut } = useActions(projectTreeDataLogic)- const { projectTreeRefEntry, shortcutNonFolderPaths, shortcutData } = useValues(projectTreeDataLogic)+ const { shortcutNonFolderPaths, shortcutData } = useValues(projectTreeDataLogic)const { openMoveToModal } = useActions(moveToLogic)-if (!projectTreeRefEntry) {return null}diff --git a/frontend/src/lib/components/Scenes/sceneFileLogic.ts b/frontend/src/lib/components/Scenes/sceneFileLogic.tsindex 5463e42eb5e7..c649f78b059f 100644--- a/frontend/src/lib/components/Scenes/sceneFileLogic.ts+++ b/frontend/src/lib/components/Scenes/sceneFileLogic.ts@@ -1,6 +1,9 @@-import { MakeLogicType, actions, afterMount, connect, kea, listeners, path } from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, selectors } from 'kea'import { subscriptions } from 'kea-subscriptions'+import { FEATURE_FLAGS } from 'lib/constants'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'import type { FileSystemEntry } from '../../../queries/schema/schema-general'@@ -8,8 +11,11 @@ import type { ProjectTreeRef } from '../../../types'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sceneFileLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogicprojectTreeRef: ProjectTreeRef | null // projectTreeDataLogicprojectTreeRefEntry: FileSystemEntry | null // projectTreeDataLogic+ fileItemsEntry: FileSystemEntry | null+ hasFileItems: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -26,17 +32,45 @@ export interface sceneFileLogicActions {}}-export type sceneFileLogicType = MakeLogicType<sceneFileLogicValues, sceneFileLogicActions>+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface sceneFileLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ fileItemsEntry: (+ projectTreeRefEntry: FileSystemEntry | null,+ featureFlags: FeatureFlagsSet+ ) => FileSystemEntry | null+ hasFileItems: (fileItemsEntry: FileSystemEntry | null) => boolean+ }+}++export type sceneFileLogicType = MakeLogicType<+ sceneFileLogicValues,+ sceneFileLogicActions,+ Record<string, any>,+ sceneFileLogicMeta+>export const sceneFileLogic = kea<sceneFileLogicType>([path(['lib', 'components', 'Scenes', 'sceneFileLogic']),connect({- values: [projectTreeDataLogic, ['projectTreeRef', 'projectTreeRefEntry']],+ values: [featureFlagLogic, ['featureFlags'], projectTreeDataLogic, ['projectTreeRef', 'projectTreeRefEntry']],actions: [projectTreeDataLogic, ['syncTypeAndRef']],}),actions({loadCurrentItem: true,}),+ selectors({+ /** The scene's project tree entry that the menu bar's file items act on. The Today layout has no project tree. */+ fileItemsEntry: [+ (s) => [s.projectTreeRefEntry, s.featureFlags],+ (projectTreeRefEntry: FileSystemEntry | null, featureFlags: FeatureFlagsSet): FileSystemEntry | null =>+ featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] ? null : projectTreeRefEntry,+ ],+ hasFileItems: [+ (s) => [s.fileItemsEntry],+ (fileItemsEntry: FileSystemEntry | null): boolean => !!fileItemsEntry,+ ],+ }),listeners(({ actions, values }) => ({loadCurrentItem: () => {const ref = values.projectTreeRefdiff --git a/frontend/src/scenes/web-analytics/WebAnalyticsSceneMenuBar.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsSceneMenuBar.tsxindex 2e4debda4618..d3b085cafaea 100644--- a/frontend/src/scenes/web-analytics/WebAnalyticsSceneMenuBar.tsx+++ b/frontend/src/scenes/web-analytics/WebAnalyticsSceneMenuBar.tsx@@ -4,6 +4,7 @@ import { router } from 'kea-router'import { IconBolt, IconDownload, IconGear, IconSearch, IconSparkles, IconStar, IconTarget, IconX } from '@posthog/icons'import { Badge, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'+import { sceneFileLogic } from 'lib/components/Scenes/sceneFileLogic'import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -11,7 +12,6 @@ import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { webAnalyticsLogic } from 'scenes/web-analytics/webAnalyticsLogic'-import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'import {SceneMenuBar,SceneMenuBarCheckboxItem,@@ -104,7 +104,7 @@ function WebAnalyticsSceneMenuBarInner(): JSX.Element {useActions(webAnalyticsLogic)const { exportTriggered } = useActions(shareNudgeLogic)const { featureFlags } = useValues(featureFlagLogic)- const { projectTreeRefEntry } = useValues(projectTreeDataLogic)+ const { hasFileItems } = useValues(sceneFileLogic)const { currentTeam } = useValues(teamLogic)const { achievementsOptOut } = useValues(webAnalyticsAchievementsPreferencesLogic)const { updateCurrentTeam } = useActions(teamLogic)@@ -116,7 +116,6 @@ function WebAnalyticsSceneMenuBarInner(): JSX.Element {const showQueryEngineToggle = !!featureFlags[FEATURE_FLAGS.SETTINGS_WEB_ANALYTICS_PRE_AGGREGATED_TABLES]const isUsingNewEngine = !!currentTeam?.modifiers?.useWebAnalyticsPreAggregatedTablesconst availableTiles = productTab === ProductTab.ANALYTICS ? ANALYTICS_TILES : []- const hasFileItems = !!projectTreeRefEntryconst handleToggleEngine = (checked: boolean): void => {updateCurrentTeam({diff --git a/products/mcp_analytics/frontend/MCPAnalyticsSceneMenuBar.tsx b/products/mcp_analytics/frontend/MCPAnalyticsSceneMenuBar.tsxindex e1ec10340af1..fbe5e9f1a17d 100644--- a/products/mcp_analytics/frontend/MCPAnalyticsSceneMenuBar.tsx+++ b/products/mcp_analytics/frontend/MCPAnalyticsSceneMenuBar.tsx@@ -1,10 +1,10 @@import { useValues } from 'kea'+import { sceneFileLogic } from 'lib/components/Scenes/sceneFileLogic'import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'import { SceneMenuBar, SceneMenuBarMenu } from '~/layout/scenes/components/SceneMenuBar'const RESOURCE_TYPE = 'mcp-analytics'@@ -18,8 +18,7 @@ export function MCPAnalyticsSceneMenuBar(): JSX.Element | null {}function MCPAnalyticsSceneMenuBarInner(): JSX.Element {- const { projectTreeRefEntry } = useValues(projectTreeDataLogic)- const hasFileItems = !!projectTreeRefEntry+ const { hasFileItems } = useValues(sceneFileLogic)return (<SceneMenuBar>