: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): gate apps and files behind simple-sidepanel (#104714)
Marius Andraaaa209dd8341
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex bfcbfac96806..bc08e7ca3fff 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -3688,6 +3688,74 @@ snapshots:hash: v1.k794b7964.33dac53a2c2f3c8945bb52917b010f00a24b8d8b213106939af1037022d4ed5e.QNBv_MCq5SJyqzj3G7AuQxGF1qLYQLIQotnO3MfqpREinsights-worldmap--default--light:hash: v1.k794b7964.a4f523dbe2e78f12ddf6c95d6e1e0b1da4457008aa42a9b83fb5e21bc4519915.sRV9jpfMOemd-Hss7Y7z4hMMwHYzM7l8Dq9i4uoJBiE+ layout-apps-and-files--apps--dark:+ hash: v1.k794b7964.ad1a766359dfddd6751c7b1b8b68a093a570b8858d9114b1c6b31f0ba29d2e28.oiVoHvBQvbrO4fyy7LdT3bZWoVBHi2FfYms29SGXNwI+ layout-apps-and-files--apps--light:+ hash: v1.k794b7964.f76afd8cc6e282e9c02ec878df4b3b4c962677c48ea8c3c15010ed563c6e840f.1RLBgJoTbw2OwI2IYcKz7q_hh_wnhfN2zrlt0JlMDjI+ layout-apps-and-files--collapsed--dark:+ hash: v1.k794b7964.419058019497189281c62514ec654c038832e17dae7c5f39f2a6e887f9251340.hwbRml-yka-mE_oa8yhLs9s_8U7QxxX3UseL8snLJMQ+ layout-apps-and-files--collapsed--light:+ hash: v1.k794b7964.4e69eef40e28d9b063759264639ee685ce796c07a623bd78aabb7cc51a6eea59.EquaH8oP-2UUsgXNQGDkK-ZZWpWsFWL2U-K1tVlOOpM+ layout-apps-and-files--dark--dark:+ hash: v1.k794b7964.ad1a766359dfddd6751c7b1b8b68a093a570b8858d9114b1c6b31f0ba29d2e28.RzYISH1Mp80FQfXTJZD0RhVYlgWDm0qPLHvjObiIIl0+ layout-apps-and-files--dark--light:+ hash: v1.k794b7964.8cdbb111d89b85408620e8bef5ef823c471eb9548f8c69dbd04573e53023d7e8.qLo2az7u5ynR88fpKa_YMBLy2oT_E6QYAsElJDy0rkA+ layout-apps-and-files--empty-starred--dark:+ hash: v1.k794b7964.d2fce2b0fc0fd48ed43dab30a94c1b4c0d84994e4750ba637575427381e2ebf7._cd0GS4RsJ8OU-MvkvBjfnnHb7PpKzLITOPsHo7PXxo+ layout-apps-and-files--empty-starred--light:+ hash: v1.k794b7964.c7c6a37454118fa89d27297f63d5be33f4f96e7a5bac5ad95d0d359db5299f8e.61EBDOwDr7wvR6Iv6IYfVbjRF48Fwp3QxYVHhFTHDhQ+ layout-apps-and-files--files--dark:+ hash: v1.k794b7964.0841bb7f32c3939650b6911817dc54b80a7b31f43733934c54429572c975a728.N6E4uDlBVYp3PYku6SioCYXZWDNHIZsGgCyu4K6eLcI+ layout-apps-and-files--files--light:+ hash: v1.k794b7964.0ea82d112a7cb5ae4be349bdae3543a9c6a1cb4ad8054a7d372a988c6cbf91bf.wM47Hp8LXO3CbNbN2V2P77XtiK550Vr2yJneapsKSA4+ layout-apps-and-files--files-dark--dark:+ hash: v1.k794b7964.0841bb7f32c3939650b6911817dc54b80a7b31f43733934c54429572c975a728.3eRQkZzI1WYgFhmfKnBELcQltH4bzjFbpq91jhTaoWo+ layout-apps-and-files--files-dark--light:+ hash: v1.k794b7964.0ea82d112a7cb5ae4be349bdae3543a9c6a1cb4ad8054a7d372a988c6cbf91bf.o6xHB2Tzxk5_ILPgXSQPzcZ6bOasJlaQf9Otv49bFDg+ layout-apps-and-files--files-empty-starred--dark:+ hash: v1.k794b7964.b9273d74f6837673fdf4cc9600ccd5c48186af00b8f11598283aabc3d62487ac.w2j4tEjWEC9_uXf5w8aquZqghIvKvAF8hDftLPXAXOw+ layout-apps-and-files--files-empty-starred--light:+ hash: v1.k794b7964.2b490c51e5691b5717f9e29e63047b025ec995621359374484117172e466eff1.R2Hc7aQ_SfXjEnE-RtJSEH7tbVoz33BvSh7YrsacsxA+ layout-apps-and-files--files-long-tree--dark:+ hash: v1.k794b7964.5cc2e1092e9667c57f102ecf1070616c772db4d57ba919788193eb0347477038.ARdi8ZDKqPZ1BlHmauE23nsAz6QoCjNfDmmQvKtdGyc+ layout-apps-and-files--files-long-tree--light:+ hash: v1.k794b7964.08f2a0a2f20aa83a4c7d202004f0dba09b18baf8ce1fa56a34847fdcadbfb0e4.Irvc-3kpDfEtzjgkX20mpRjKInyccUd7hre-yjuOPyI+ layout-apps-and-files--files-narrow--dark:+ hash: v1.k794b7964.f749ff197546d3d2f1b88c2018843d79f97e2135ca95acc9083f3503510948a9.WXbLG92Rk8NY0s-MYyvgeKE02kdv5adwyW9XWeWvCkc+ layout-apps-and-files--files-narrow--light:+ hash: v1.k794b7964.90788987cd337a71ffe2691400b5da016b80948ab6c88ce9b8c67d5a44911ea5._oL7iRi6mu1rwOj1pyBfe3-rnfvWpANEBY_UZk8gWXk+ layout-apps-and-files--files-recents-collapsed--dark:+ hash: v1.k794b7964.f1a2784553f05553104eee2802be1a6e264d2b850ed068df4168b502bd429b1e.Jx9NaOZ1g0xwily-5UMFdIbVdagpUjidumywyvvpTIs+ layout-apps-and-files--files-recents-collapsed--light:+ hash: v1.k794b7964.a826987843c76568b6d5cfb159428f5bc4556ae1ee9f55ea33752099adfd6123.i31Wes7W6iXfLt9h4_QEExq0Cgzn6J3GFy24C8fVRLI+ layout-apps-and-files--flag-off--dark:+ hash: v1.k794b7964.1d2bc7478dae3a6a9f01dea82d349773021591a51bfc8350ad86a9427400b980.pjx9o1-yZUZYLwWK1yCxPmCE6XmaK2UKX7yX5Bdv1nk+ layout-apps-and-files--flag-off--light:+ hash: v1.k794b7964.80dd55f32c34e731232079e38f14fd3fe85fd8ce06d14cf454b0d007260d51ed.olU2lOlJe0_rGTwyXbmCPUKfw6oawnZjFYFEKVnsHL8+ layout-apps-and-files--flag-off-after-files--dark:+ hash: v1.k794b7964.1d2bc7478dae3a6a9f01dea82d349773021591a51bfc8350ad86a9427400b980.rD0eGdg7BmBHThbgbSkhMpC8W9GzPJRrrR4VDReHZkY+ layout-apps-and-files--flag-off-after-files--light:+ hash: v1.k794b7964.80dd55f32c34e731232079e38f14fd3fe85fd8ce06d14cf454b0d007260d51ed.wkTL6HiTfXqauNqpx1w8GCgQRJNQuS1A5ylQ2ElOelw+ layout-apps-and-files--flag-off-collapsed--dark:+ hash: v1.k794b7964.d6afb3e4a9cb6549b97b74fae1be4bb9573a02ef08694137012a5af092454acb.TBJuyHaRmCsNMR8J5dKYCENSAk6x8G1DLDmkBYUsWK0+ layout-apps-and-files--flag-off-collapsed--light:+ hash: v1.k794b7964.3ea4f9115eeb0c26070c6a8b6ef85679a6b15433c00a5f1660e73589af48852c.TRVnhz5zpRuhAc9L04LtgRvjW2dqvPZzIU7yxeYfJqo+ layout-apps-and-files--flag-off-flat-nav--dark:+ hash: v1.k794b7964.9e49fa9186ab22c3c49f29bf10aac1dfc8416695424406957cae5f76ce09c5c4.EBwUGnLe5ovLt2yP5AT0NTyPVv047rBK5Rl1ZxzctTE+ layout-apps-and-files--flag-off-flat-nav--light:+ hash: v1.k794b7964.394c03467e2594ff67bc80ef82e12abdd02a572bf94fa4d8efeb6175899444cf.kbwibhKTNB1UnDA7vr6xgoAFGLCz6WDD4PCylFdYW1Q+ layout-apps-and-files--narrow--dark:+ hash: v1.k794b7964.cc2abcd2545e7b2a255b16192dca1cde3adfd35f3d127aa4aa4bc6fb7ead828a.Wc7nzVQ_5Hajo65eJ6IBc5RJpG95Ul8Ao51qHnew1-4+ layout-apps-and-files--narrow--light:+ hash: v1.k794b7964.4ed6820fc944c10d5976c2c1f983304195d03fc6e1db5b93d87313a29149e464.oQKAXl3Yamb-jV2YngJJjvZHSJpG6jdWmrCEKjn11HM+ layout-apps-and-files--no-results--dark:+ hash: v1.k794b7964.bf995b481f1e6bb81197aae7e6318d39e91dc49eebecbf298f1d16a255330f3f.ozybVX3dJMAn9hfJMAzOs0Cgxw_q3nR7EGSyH3wJzh4+ layout-apps-and-files--no-results--light:+ hash: v1.k794b7964.7309568f7fd5d46681001f547a5cda89ee51c1289e68948c38e61ba5b82ef59d.0_8jAAQ7TnKvauBCdP2q9EZH66DgRM1QH5WJInuVovQ+ layout-apps-and-files--search--dark:+ hash: v1.k794b7964.e6a7236cbaa1a5530b0852dcd8b96a5e5ede18d51fff382fd2fbc0ed38499629.keu2JbNJYulSkSEQ0u0Mf9BgTGq-AwusNFvYRVoWt9s+ layout-apps-and-files--search--light:+ hash: v1.k794b7964.a85d66153be5eac425203199a972841836cb4304db9e4fddae78fc2989e860f9.xOCcUQ4og59re2zFHEUSv6tDnAxW4f-nj9TBxlmXz3wlayout-flat-nav-browse--default--dark:hash: v1.k794b7964.5d1f1b535bb3492e1ecdfa3e1acac30e856bcacb109136cf4b88654a8fa2bfcb.N4pOX84PDiTGfw5A6cgk634GGZ5U2Z-1QQNM82ZTp8Ylayout-flat-nav-browse--default--light:diff --git a/frontend/src/layout/panel-layout/PanelLayoutPanel.tsx b/frontend/src/layout/panel-layout/PanelLayoutPanel.tsxindex a53a26a7fcb5..4d5ddcfb7ab1 100644--- a/frontend/src/layout/panel-layout/PanelLayoutPanel.tsx+++ b/frontend/src/layout/panel-layout/PanelLayoutPanel.tsx@@ -20,6 +20,7 @@ import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { navigation3000Logic } from '../navigation-3000/navigationLogic'interface PanelLayoutPanelProps {+ layout?: 'panel' | 'inline'/** Names the panel in the DOM, so click maps and analytics can scope to one second-level nav. */panelName: stringsearchPlaceholder?: string@@ -60,6 +61,7 @@ const panelLayoutPanelVariants = cva({export function PanelLayoutPanel({panelName,+ layout = 'panel',searchField,panelActionsNewSceneLayout,children,@@ -80,11 +82,13 @@ export function PanelLayoutPanel({const panelContents = (<navclassName={cn(- panelLayoutPanelVariants({- isLayoutNavCollapsed,- isMobileLayout,- panelWillHide,- })+ layout === 'inline'+ ? 'flex flex-col h-full min-h-0'+ : panelLayoutPanelVariants({+ isLayoutNavCollapsed,+ isMobileLayout,+ panelWillHide,+ }))}ref={containerRef}data-attr={`nav-panel-${panelName}`}@@ -97,10 +101,17 @@ export function PanelLayoutPanel({>{searchField || filterDropdown || sortDropdown ? (<>- <div className="flex gap-1 p-1 items-center justify-between">- {searchField ?? null}+ <div+ className={cn(+ 'flex gap-1 p-1 items-center justify-between',+ layout === 'inline' && 'flex-nowrap'+ )}+ >+ <div className={layout === 'inline' ? 'flex-1 min-w-0' : 'contents'}>+ {searchField ?? null}+ </div>- <div className="flex gap-px">+ <div className={cn('flex gap-px', layout === 'inline' && 'shrink-0')}>{filterDropdown || sortDropdown ? (<div className="flex gap-px">{filterDropdown ?? null}@@ -129,17 +140,19 @@ export function PanelLayoutPanel({</DropdownMenu>)}- <ButtonPrimitive- onClick={() => {- closePanel()- }}- tooltip="Close panel"- iconOnly- data-attr="tree-panel-close-panel-button"- size="sm"- >- <IconX className="text-tertiary size-3" />- </ButtonPrimitive>+ {layout === 'panel' && (+ <ButtonPrimitive+ onClick={() => {+ closePanel()+ }}+ tooltip="Close panel"+ iconOnly+ data-attr="tree-panel-close-panel-button"+ size="sm"+ >+ <IconX className="text-tertiary size-3" />+ </ButtonPrimitive>+ )}</div></div></>@@ -150,6 +163,10 @@ export function PanelLayoutPanel({</nav>)+ if (layout === 'inline') {+ return panelContents+ }+return (<ResizableElementclassName="absolute left-full h-full"diff --git a/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx b/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsxindex 90a2f3266e02..497f8408607d 100644--- a/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx+++ b/frontend/src/layout/panel-layout/ProjectTree/ProjectTree.tsx@@ -1,11 +1,12 @@import { BindLogic, useActions, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'-import { RefObject, useEffect, useRef, useState } from 'react'+import { ReactNode, RefObject, useEffect, useRef, useState } from 'react'import { IconCheckbox, IconChevronRight, IconEllipsis, IconFolderPlus, IconPlusSmall, IconStar } from '@posthog/icons'import { itemSelectModalLogic } from 'lib/components/FileSystem/ItemSelectModal/itemSelectModalLogic'+import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'import { dayjs } from 'lib/dayjs'import { useLocalStorage } from 'lib/hooks/useLocalStorage'import { LemonTag } from 'lib/lemon-ui/LemonTag'@@ -40,8 +41,12 @@ import { TreeSortDropdownMenu } from './TreeSortDropdownMenu'import { calculateMovePath } from './utils'interface ProjectTreeBaseProps {+ layout?: 'panel' | 'inline'+ beforeTree?: ReactNode+ showShortcutHelp?: booleanlogicKey?: string // key override?root?: string+ shortcutScope?: 'apps' | 'files'showRecents?: boolean // whether to show recents in the treesearchPlaceholder?: stringtreeSize?: LemonTreeSize@@ -110,8 +115,9 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {const {logicKey,root,+ shortcutScope,onlyTree = false,- disableScroll = onlyTree,+ disableScroll = onlyTree || !!props.beforeTree,searchPlaceholder,treeSize = 'default',showRecents,@@ -124,7 +130,7 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {const [uniqueKey] = useState(() => `project-tree-${counter++}`)const { viableItems, shortcutEntryIdMap } = useValues(projectTreeDataLogic)const { reorderShortcutByDrag } = useActions(projectTreeDataLogic)- const projectTreeLogicProps = { key: logicKey ?? uniqueKey, root, isActiveInPanel }+ const projectTreeLogicProps = { key: logicKey ?? uniqueKey, root, shortcutScope, isActiveInPanel }const {fullFileSystemFiltered,lastViewedId,@@ -188,7 +194,11 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {}if (fullFileSystemFiltered.length <= 5) {- if (root === 'shortcuts://' && (fullFileSystemFiltered.length === 0 || !shortcutHelperDismissed)) {+ if (+ props.showShortcutHelp !== false &&+ root === 'shortcuts://' &&+ (fullFileSystemFiltered.length === 0 || !shortcutHelperDismissed)+ ) {treeData.push({id: 'products/shortcuts-helper-category',name: 'Starred items',@@ -622,6 +632,7 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {return (<PanelLayoutPanelpanelName={props.panelName}+ layout={props.layout}searchField={<BindLogic logic={projectTreeLogic} props={projectTreeLogicProps}><TreeSearchField@@ -710,7 +721,14 @@ export function ProjectTree(props: ProjectTreeProps): JSX.Element {</>)}- {tree}+ {props.beforeTree ? (+ <ScrollableShadows direction="vertical" className="flex-1 min-h-0" styledScrollbars>+ {props.beforeTree}+ {tree}+ </ScrollableShadows>+ ) : (+ tree+ )}</PanelLayoutPanel>)}diff --git a/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx b/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsxindex a0ce8fb2355a..968479faef36 100644--- a/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx+++ b/frontend/src/layout/panel-layout/ProjectTree/menus/MenuItems.tsx@@ -13,6 +13,7 @@ import {import { linkToLogic } from 'lib/components/FileSystem/LinkTo/linkToLogic'import { moveToLogic } from 'lib/components/FileSystem/MoveTo/moveToLogic'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import {@@ -70,7 +71,8 @@ export function MenuItems({showSelectMenuOption = true,}: MenuItemsProps): JSX.Element {const [uniqueKey] = useState(() => `project-tree-${counter++}`)- const { shortcutNonFolderPaths } = useValues(projectTreeDataLogic)+ const { shortcutNonFolderPaths, shortcutData, shortcutEntryIdMap, shortcutDataLoading } =+ useValues(projectTreeDataLogic)const { deleteShortcut, addShortcutItem } = useActions(projectTreeDataLogic)const { groupTypes } = useValues(groupAnalyticsConfigLogic)const { deleteGroupType } = useActions(groupAnalyticsConfigLogic)@@ -154,9 +156,20 @@ export function MenuItems({</>) : null+ const isSimpleSidepanelEnabled = useFeatureFlag('SIMPLE_SIDEPANEL')const isItemAFolder = item.record?.type === 'folder'const itemShortcutPath = joinPath([splitPath(item.record?.path).pop() ?? 'Unnamed'])const isItemAlreadyInShortcut = !isItemAFolder && shortcutNonFolderPaths.has(itemShortcutPath)+ const shortcutId =+ shortcutEntryIdMap.get(item.id) ??+ shortcutData.find((entry) =>+ isItemAFolder+ ? entry.type === 'folder' && entry.ref === item.record?.path+ : entry.type !== 'folder' &&+ (item.record?.ref+ ? entry.type === item.record.type && entry.ref === item.record.ref+ : entry.path === itemShortcutPath)+ )?.idreturn (<>@@ -184,7 +197,7 @@ export function MenuItems({MenuItem={MenuItem}resetPanelLayout={resetPanelLayout}/>- <MenuSeparator />+ {!isSimpleSidepanelEnabled && <MenuSeparator />}</>) : null}@@ -240,7 +253,7 @@ export function MenuItems({<MenuSeparator /></>) : null}- {item.record?.path ? (+ {!isSimpleSidepanelEnabled && item.record?.path ? ((root === 'shortcuts://' || root === 'custom-products://') &&(item.id.startsWith('shortcuts://') || item.id.startsWith('shortcuts/')) ? (<MenuItem@@ -454,6 +467,37 @@ export function MenuItems({<ButtonPrimitive menuItem>Delete group type</ButtonPrimitive></MenuItem>) : null}+ {isSimpleSidepanelEnabled && item.record?.path && (shortcutId || root !== 'custom-products://') ? (+ <>+ {(!isItemAFolder || !shortcutEntryIdMap.has(item.id) || checkedItemCountNumeric > 0) && (+ <MenuSeparator />+ )}+ <MenuItem+ asChild+ disabled={shortcutDataLoading}+ onClick={(e) => {+ e.stopPropagation()+ if (!shortcutDataLoading && item.record) {+ if (shortcutId) {+ deleteShortcut(shortcutId)+ } else {+ addShortcutItem(item.record as FileSystemEntry)+ }+ }+ }}+ data-attr={+ shortcutId+ ? 'tree-item-menu-remove-from-shortcuts-button'+ : 'tree-item-menu-add-to-shortcuts-button'+ }+ >+ <ButtonPrimitive menuItem disabled={shortcutDataLoading}>+ <IconStar className="size-4 text-tertiary" />+ <span>{shortcutId ? 'Remove from starred' : 'Add to starred'}</span>+ </ButtonPrimitive>+ </MenuItem>+ </>+ ) : null}</>)}diff --git a/frontend/src/layout/panel-layout/ProjectTree/projectTreeLogic.tsx b/frontend/src/layout/panel-layout/ProjectTree/projectTreeLogic.tsxindex 6d92b7003b6b..3ed3afecb409 100644--- a/frontend/src/layout/panel-layout/ProjectTree/projectTreeLogic.tsx+++ b/frontend/src/layout/panel-layout/ProjectTree/projectTreeLogic.tsx@@ -69,6 +69,7 @@ export interface ProjectTreeLogicProps {includeRoot?: booleanhideFolders?: string[]isActiveInPanel?: boolean+ shortcutScope?: 'apps' | 'files'}const FOLDER_LOADING = [@@ -494,7 +495,8 @@ export interface projectTreeLogicMeta {searchTerm: string,arg: any,arg2: any,- arg3: any+ arg3: any,+ arg4: any) => TreeDataItem[]treeTableColumnOffsets: (treeTableColumnSizes: number[]) => number[]checkedItemCountNumeric: (checkedItems: Record<string, boolean>) => number@@ -1119,8 +1121,16 @@ export const projectTreeLogic = kea<projectTreeLogicType>([(_, props) => props.root,(_, props) => props.includeRoot,(_, props) => props.hideFolders,+ (_, props) => props.shortcutScope,],- (fullFileSystem: TreeDataItem[], searchTerm: string, root, includeRoot, hideFolders): TreeDataItem[] => {+ (+ fullFileSystem: TreeDataItem[],+ searchTerm: string,+ root,+ includeRoot,+ hideFolders,+ shortcutScope: ProjectTreeLogicProps['shortcutScope']+ ): TreeDataItem[] => {let firstFolders = fullFileSystem// Filter out folders specified in hideFolders prop@@ -1150,6 +1160,13 @@ export const projectTreeLogic = kea<projectTreeLogicType>([}}+ if (root === 'shortcuts://' && shortcutScope) {+ firstFolders = firstFolders.filter((item) => {+ const isApp = item.record?.type !== 'folder' && !item.record?.ref+ return shortcutScope === 'apps' ? isApp : !isApp+ })+ }+function addRoot(tree: TreeDataItem[]): TreeDataItem[] {if (includeRoot) {return [diff --git a/frontend/src/layout/panel-layout/ProjectTree/utils.tsx b/frontend/src/layout/panel-layout/ProjectTree/utils.tsxindex 4710b47bb564..87f105e8a080 100644--- a/frontend/src/layout/panel-layout/ProjectTree/utils.tsx+++ b/frontend/src/layout/panel-layout/ProjectTree/utils.tsx@@ -32,7 +32,7 @@ export function getCategoryOrder(category: string | undefined): number {}// Define the order of categories in the data management panel-const DATA_MANAGEMENT_PANEL_ORDER: Record<string, number> = {+export const DATA_MANAGEMENT_PANEL_ORDER: Record<string, number> = {Pipeline: 1,Schema: 2,Tools: 3,diff --git a/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx b/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsxnew file mode 100644index 000000000000..3269a96e4b39--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx@@ -0,0 +1,179 @@+import type { Meta, StoryObj } from '@storybook/react'+import { useActions } from 'kea'++import { FEATURE_FLAGS } from 'lib/constants'+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'++import { mswDecorator } from '~/mocks/browser'+import { FileSystemEntry } from '~/queries/schema/schema-general'++import { NavExperimentTab, panelLayoutLogic } from '../panelLayoutLogic'+import { getDefaultTreeDataAndPeople, getDefaultTreeProducts } from '../ProjectTree/defaultTree'+import { projectTreeDataLogic } from '../ProjectTree/projectTreeDataLogic'+import { NavBar } from './NavBar'+import { navAppsTabLogic } from './tabs/navAppsTabLogic'+import { navRecentsLogic } from './tabs/navRecentsLogic'++const files: FileSystemEntry[] = [+ { id: 'folder-1', path: 'Getting started', type: 'folder' },+ { id: 'dashboard-1', path: 'Getting started/Overview', type: 'dashboard', ref: '1', href: '/dashboard/1' },+ {+ id: 'insight-1',+ path: 'Getting started/Weekly signups',+ type: 'insight',+ ref: 'signup01',+ href: '/insights/signup01',+ },+ { id: 'folder-2', path: 'Product research', type: 'folder' },+ {+ id: 'notebook-1',+ path: 'Product research/Onboarding notes',+ type: 'notebook',+ ref: 'notes001',+ href: '/notebooks/notes001',+ },+ { id: 'flag-1', path: 'New checkout', type: 'feature_flag', ref: '1', href: '/feature_flags/1' },+]+const starred: FileSystemEntry[] = [+ { id: 'star-1', path: 'Product analytics', type: 'product_analytics', href: '/insights' },+ { id: 'star-2', path: 'Overview', type: 'dashboard', ref: '1', href: '/dashboard/1' },+ { id: 'star-3', path: 'Product research', type: 'folder', ref: 'Product research' },+]++function SidebarStory({+ tab = 'home',+ search = '',+ collapsed = false,+ empty = false,+ recentsCollapsed = false,+}: {+ tab?: NavExperimentTab+ search?: string+ collapsed?: boolean+ empty?: boolean+ recentsCollapsed?: boolean+}): JSX.Element {+ const { setNavExperimentTab, toggleLayoutNavCollapsed, clearActivePanelIdentifier } = useActions(panelLayoutLogic)+ const { setRecentsCollapsed } = useActions(navRecentsLogic)+ const { setSearch } = useActions(navAppsTabLogic)+ const { loadShortcutsSuccess } = useActions(projectTreeDataLogic)+ useOnMountEffect(() => {+ setNavExperimentTab(tab)+ toggleLayoutNavCollapsed(collapsed)+ clearActivePanelIdentifier()+ setSearch(search)+ setRecentsCollapsed(recentsCollapsed)+ loadShortcutsSuccess(empty ? [] : starred)+ })+ return <NavBar />+}++const meta: Meta<typeof SidebarStory> = {+ title: 'Layout/Apps and files',+ component: SidebarStory,+ parameters: {+ layout: 'fullscreen',+ featureFlags: [+ ...new Set(+ [...getDefaultTreeProducts(), ...getDefaultTreeDataAndPeople()].flatMap((item) =>+ item.flag ? [item.flag] : []+ )+ ),+ FEATURE_FLAGS.PRODUCT_AUTONOMY,+ FEATURE_FLAGS.SIMPLE_SIDEPANEL,+ ],+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/environments/:team_id/file_system': ({ request: req }) => {+ const params = new URL(req.url).searchParams+ const parent = params.get('parent')+ const search = params.get('search')?.toLowerCase() ?? ''+ const results = files.filter((file) =>+ parent !== null+ ? file.path.split('/').slice(0, -1).join('/') === parent+ : file.type !== 'folder' && file.path.toLowerCase().includes(search)+ )+ return [200, { results, count: results.length, next: null, has_more: false }]+ },+ '/api/environments/:team_id/file_system_shortcut/': [200, { results: starred }],+ },+ post: {+ '/api/environments/:team_id/file_system_shortcut/': async ({ request: req }) => [+ 201,+ { ...((await req.json()) as object), id: 'star-new' },+ ],+ },+ delete: {+ '/api/environments/:team_id/file_system_shortcut/:id/': [204],+ },+ }),+ ],+}+export default meta++type Story = StoryObj<typeof SidebarStory>+export const Apps: Story = {}+export const Files: Story = { args: { tab: 'files' } }+export const Search: Story = { args: { search: 'data' } }+export const NoResults: Story = { args: { search: 'nothing-matches' } }+export const Collapsed: Story = { args: { collapsed: true } }+export const Narrow: Story = {+ decorators: [+ (Story) => (+ <div className="[--project-navbar-width:180px]">+ <Story />+ </div>+ ),+ ],+}+export const FilesNarrow: Story = { args: { tab: 'files' }, decorators: Narrow.decorators }+export const Dark: Story = { globals: { theme: 'dark' } }+export const FilesDark: Story = { args: { tab: 'files' }, globals: { theme: 'dark' } }+export const EmptyStarred: Story = {+ args: { empty: true },+ decorators: [mswDecorator({ get: { '/api/environments/:team_id/file_system_shortcut/': [200, { results: [] }] } })],+}++export const FilesEmptyStarred: Story = {+ ...EmptyStarred,+ args: { tab: 'files', empty: true },+}++export const FilesRecentsCollapsed: Story = { args: { tab: 'files', recentsCollapsed: true } }+export const FilesLongTree: Story = {+ args: { tab: 'files' },+ decorators: [+ mswDecorator({+ get: {+ '/api/environments/:team_id/file_system': [+ 200,+ {+ results: Array.from({ length: 40 }, (_, index) => ({+ id: `long-file-${index}`,+ path: `Report ${String(index + 1).padStart(2, '0')}`,+ type: 'dashboard',+ ref: String(index + 1000),+ href: `/dashboard/${index + 1000}`,+ })),+ count: 40,+ next: null,+ has_more: false,+ },+ ],+ },+ }),+ ],+}++export const FlagOff: Story = { parameters: { featureFlags: [] } }+export const FlagOffAfterFiles: Story = {+ args: { tab: 'files', recentsCollapsed: true },+ parameters: { featureFlags: [] },+}+export const FlagOffCollapsed: Story = { args: { collapsed: true }, parameters: { featureFlags: [] } }+export const FlagOffFlatNav: Story = {+ args: { tab: 'files', recentsCollapsed: true },+ parameters: { featureFlags: [FEATURE_FLAGS.FLAT_NAV] },+}diff --git a/frontend/src/layout/panel-layout/navbar/NavBar.tsx b/frontend/src/layout/panel-layout/navbar/NavBar.tsxindex cd2e29402c62..f9dde654498e 100644--- a/frontend/src/layout/panel-layout/navbar/NavBar.tsx+++ b/frontend/src/layout/panel-layout/navbar/NavBar.tsx@@ -7,7 +7,7 @@ import { router } from 'kea-router'import posthog from 'posthog-js'import { Suspense, useEffect, useRef } from 'react'-import { IconApps, IconChat, IconChevronRight } from '@posthog/icons'+import { IconApps, IconChat, IconChevronRight, IconFolderOpen } from '@posthog/icons'import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'import { commandLogic } from 'lib/components/Command/commandLogic'@@ -38,7 +38,9 @@ import { navigation3000Logic } from '../../navigation-3000/navigationLogic'import { NavBarFooter } from './NavBarFooter'import { PanelLayoutPanels } from './PanelLayoutPanels'import { FlatNavBrowse } from './tabs/flat-nav/FlatNavBrowse'+import { NavTabApps } from './tabs/NavTabApps'import { NavTabBrowse } from './tabs/NavTabBrowse'+import { NavTabFiles } from './tabs/NavTabFiles'const NavTabChat = lazyWithRetry(() => import('./tabs/NavTabChat').then((m) => ({ default: m.NavTabChat })))const navBarStyles = cva({@@ -98,6 +100,13 @@ export function PanelIndicatorIcon(): JSX.Element | null {)}+// The Apps tab keeps the persisted tab ID and analytics identifiers used by Browse.+const SIMPLE_TAB_CONFIG: { id: NavExperimentTab; label: string; icon: JSX.Element }[] = [+ { id: 'home', label: 'Apps', icon: <IconApps /> },+ { id: 'files', label: 'Files', icon: <IconFolderOpen /> },+ { id: 'chat', label: 'Chat', icon: <IconChat className="text-ai" /> },+]+const TAB_CONFIG: { id: NavExperimentTab; label: string; icon: JSX.Element }[] = [{ id: 'home', label: 'Browse', icon: <IconApps /> },{ id: 'chat', label: 'Chat', icon: <IconChat className="text-ai" /> },@@ -123,7 +132,13 @@ export function NavBar(): JSX.Element {const { mobileLayout: isMobileLayout } = useValues(navigation3000Logic)const { toggleCommand } = useActions(commandLogic)const { sidebarDensity } = useValues(uiCustomizationLogic)+ const isSimpleSidepanelEnabled = useFeatureFlag('SIMPLE_SIDEPANEL')const isFlatNavEnabled = useFeatureFlag('FLAT_NAV', 'test')+ const activeTab =+ !isSimpleSidepanelEnabled &&+ (navExperimentActiveTab === 'files' || (isLayoutNavCollapsed && navExperimentActiveTab === 'chat'))+ ? 'home'+ : navExperimentActiveTabconst resizerLogicProps: ResizerLogicProps = {logicKey: 'panel-layout-navbar',@@ -172,7 +187,8 @@ export function NavBar(): JSX.Element {isLayoutNavCollapsed,isMobileLayout,}),- isLayoutNavCollapsed && 'gap-px'+ isLayoutNavCollapsed && 'gap-px',+ isSimpleSidepanelEnabled && '@container/sidebar')}data-nav-density={sidebarDensity}ref={containerRef}@@ -185,54 +201,61 @@ export function NavBar(): JSX.Element {><divclassName={cn('flex gap-1 rounded-md w-full px-2 pt-2 pb-1', {+ 'items-center': isSimpleSidepanelEnabled,'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} />}+ {isSimpleSidepanelEnabled ? (+ <NavSearchButton toggleCommand={toggleCommand} showShortcut={!isLayoutNavCollapsed} />+ ) : (+ <>+ {/* Collapsed nav has no room for the search bar, so it keeps the icon-only trigger */}+ {isLayoutNavCollapsed && <NavSearchButton toggleCommand={toggleCommand} />}- {isLayoutNavCollapsed && (- <ButtonPrimitive- className="group w-full justify-center"- data-attr="nav-tab-chat-collapsed"- iconOnly- tooltip="Chat"- tooltipPlacement="right"- active={activePanelIdentifier === 'Chat'}- onClick={() => {- const isOpening = activePanelIdentifier !== 'Chat'- posthog.capture('nav chat panel toggled', {- is_open: isOpening,- })- handlePanelTriggerClick('Chat')- if (isOpening) {- router.actions.push(urls.ai())- }- }}- >- <span- className={cn(- 'relative flex size-4 text-secondary group-hover:text-primary opacity-50 group-hover:opacity-100 transition-all duration-50',- activePanelIdentifier === 'Chat' && 'text-primary opacity-100'- )}- >- <IconChat- className={cn(- 'text-secondary group-hover:text-ai',- activePanelIdentifier === 'Chat' && 'text-primary'- )}- />+ {isLayoutNavCollapsed && (+ <ButtonPrimitive+ className="group w-full justify-center"+ data-attr="nav-tab-chat-collapsed"+ iconOnly+ tooltip="Chat"+ tooltipPlacement="right"+ active={activePanelIdentifier === 'Chat'}+ onClick={() => {+ const isOpening = activePanelIdentifier !== 'Chat'+ posthog.capture('nav chat panel toggled', {+ is_open: isOpening,+ })+ handlePanelTriggerClick('Chat')+ if (isOpening) {+ router.actions.push(urls.ai())+ }+ }}+ >+ <span+ className={cn(+ 'relative flex size-4 text-secondary group-hover:text-primary opacity-50 group-hover:opacity-100 transition-all duration-50',+ activePanelIdentifier === 'Chat' && 'text-primary opacity-100'+ )}+ >+ <IconChat+ className={cn(+ 'text-secondary group-hover:text-ai',+ activePanelIdentifier === 'Chat' && 'text-primary'+ )}+ />- <PanelIndicatorIcon />- </span>- </ButtonPrimitive>+ <PanelIndicatorIcon />+ </span>+ </ButtonPrimitive>+ )}+ </>)}</div></div>- {!isLayoutNavCollapsed && (+ {!isSimpleSidepanelEnabled && !isLayoutNavCollapsed && (<div className="px-2 py-1"><NavSearchBar toggleCommand={toggleCommand} /></div>@@ -240,48 +263,78 @@ export function NavBar(): JSX.Element {<Tabs.RootclassName="z-[var(--z-main-nav)] flex flex-col flex-1 overflow-hidden"- value={isLayoutNavCollapsed && navExperimentActiveTab === 'chat' ? 'home' : navExperimentActiveTab}+ value={activeTab}onValueChange={(value) => {posthog.capture('nav tab clicked', { tab: value })setNavExperimentTab(value as NavExperimentTab)+ if (isSimpleSidepanelEnabled) {+ clearActivePanelIdentifier()+ showLayoutPanel(false)+ if (isLayoutNavCollapsed) {+ toggleLayoutNavCollapsed(false)+ }+ }if (value === 'chat') {router.actions.push(urls.ai())}}}orientation={isLayoutNavCollapsed ? 'vertical' : 'horizontal'}>- <div className={cn('p-1', isLayoutNavCollapsed && 'hidden')}>- <Tabs.List className="relative flex items-center gap-1 shrink-0 z-0 p-1 rounded-lg bg-(--color-bg-fill-highlight-50) dark:bg-surface-primary">- {TAB_CONFIG.map((tab) => (+ <div className={cn('p-1', !isSimpleSidepanelEnabled && isLayoutNavCollapsed && 'hidden')}>+ <Tabs.List+ className={cn(+ 'relative flex items-center gap-1 shrink-0 z-0 p-1 rounded-lg bg-(--color-bg-fill-highlight-50) dark:bg-surface-primary',+ isSimpleSidepanelEnabled && isLayoutNavCollapsed && 'flex-col'+ )}+ >+ {(isSimpleSidepanelEnabled ? SIMPLE_TAB_CONFIG : TAB_CONFIG).map((tab) => (<Tabs.Tabkey={tab.id}value={tab.id}+ onClick={() => {+ if (isSimpleSidepanelEnabled && isLayoutNavCollapsed) {+ toggleLayoutNavCollapsed(false)+ }+ }}render={(props) => (<ButtonPrimitive{...props}- className="group data-[composite-item-active]:bg-surface-tertiary w-1/2 justify-center"- data-attr={`nav-tab-${tab.id}`}+ className={cn(+ 'group data-[composite-item-active]:bg-surface-tertiary justify-center',+ isSimpleSidepanelEnabled ? 'flex-1 min-w-0' : 'w-1/2'+ )}+ iconOnly={isSimpleSidepanelEnabled && isLayoutNavCollapsed}+ tooltip={isSimpleSidepanelEnabled ? tab.label : undefined}+ aria-label={tab.label}+ data-attr={+ isSimpleSidepanelEnabled && isLayoutNavCollapsed && tab.id === 'chat'+ ? 'nav-tab-chat-collapsed'+ : `nav-tab-${tab.id}`+ }><spanclassName={cn('flex size-4',- navExperimentActiveTab === tab.id+ activeTab === tab.id? 'text-primary': 'text-secondary group-hover:text-primary')}>{tab.icon}</span>- <span- className={cn(- 'text-xs',- navExperimentActiveTab === tab.id- ? 'text-primary'- : 'text-secondary group-hover:text-primary'- )}- >- {tab.label}- </span>+ {!isLayoutNavCollapsed && (+ <span+ className={cn(+ 'text-xs',+ isSimpleSidepanelEnabled && '@max-[200px]/sidebar:hidden',+ activeTab === tab.id+ ? 'text-primary'+ : 'text-secondary group-hover:text-primary'+ )}+ >+ {tab.label}+ </span>+ )}</ButtonPrimitive>)}/>@@ -289,10 +342,31 @@ export function NavBar(): JSX.Element {</Tabs.List></div>- <div className="flex-1 overflow-hidden relative">+ <div+ className={cn(+ 'flex-1 overflow-hidden relative',+ isSimpleSidepanelEnabled && isLayoutNavCollapsed && '[&>*]:hidden'+ )}+ ><Tabs.Panel value="home" className="absolute inset-0 flex flex-col" keepMounted tabIndex={-1}>- {isFlatNavEnabled ? <FlatNavBrowse /> : <NavTabBrowse />}+ {isSimpleSidepanelEnabled ? (+ <NavTabApps />+ ) : isFlatNavEnabled ? (+ <FlatNavBrowse />+ ) : (+ <NavTabBrowse />+ )}</Tabs.Panel>+ {isSimpleSidepanelEnabled && visitedNavTabs.includes('files') && (+ <Tabs.Panel+ value="files"+ className="absolute inset-0 flex flex-col"+ keepMounted+ tabIndex={-1}+ >+ <NavTabFiles />+ </Tabs.Panel>+ )}{/* Lazy until first activated: the visited list only ever grows, so oncemounted the panel never unmounts — keepMounted then preserves it acrosstab switches. Users who never open chat never pay for its chunk. */}@@ -324,7 +398,7 @@ export function NavBar(): JSX.Element {<div className="h-px bg-border-primary " /></div>- <div className="p-1">+ <div className={cn('p-1', !isSimpleSidepanelEnabled && isLayoutNavCollapsed && 'hidden')}><NavBarFooter isLayoutNavCollapsed={isLayoutNavCollapsed} /></div></Tabs.Root>diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppMenu.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppMenu.tsxnew file mode 100644index 000000000000..e521f80fef49--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppMenu.tsx@@ -0,0 +1,124 @@+import { useActions, useValues } from 'kea'+import { combineUrl } from 'kea-router'++import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { LemonMenuItems, LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu'+import { sessionRecordingCollectionsLogic } from 'scenes/session-recordings/collections/sessionRecordingCollectionsLogic'+import { sessionRecordingSavedFiltersLogic } from 'scenes/session-recordings/filters/sessionRecordingSavedFiltersLogic'+import { urls } from 'scenes/urls'++import { dashboardsModel } from '~/models/dashboardsModel'+import { ReplayTabs } from '~/types'++import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'++export function NavAppMenu({ product }: { product: string }): JSX.Element {+ const { treeItemsNew } = useValues(projectTreeDataLogic)+ const { pinnedDashboards, dashboardsLoading, loadDashboardsFailed } = useValues(dashboardsModel)+ const { loadDashboardsIfNeeded, loadDashboards } = useActions(dashboardsModel)+ const { savedFilters, savedFiltersLoading, loadSavedFiltersFailed } = useValues(sessionRecordingSavedFiltersLogic)+ const { loadSavedFilters } = useActions(sessionRecordingSavedFiltersLogic)+ const { playlists, playlistsLoading, loadPlaylistsFailed } = useValues(sessionRecordingCollectionsLogic)+ const { loadPlaylists } = useActions(sessionRecordingCollectionsLogic)++ let items: LemonMenuItems+ if (product === 'Product analytics') {+ items = [+ {+ title: 'Create new insight type',+ items: [...(treeItemsNew.find(({ name }) => name === 'Insight')?.children ?? [])]+ .sort((a, b) => (a.visualOrder ?? 0) - (b.visualOrder ?? 0))+ .map((item) => ({ label: item.name, icon: <>{item.icon}</>, to: item.record?.href })),+ },+ ]+ } else if (product === 'Dashboards') {+ items = [+ {+ title: 'Pinned dashboards',+ items: loadDashboardsFailed+ ? [+ {+ label: 'Could not load dashboards. Reopen this menu to retry.',+ disabledReason: 'Could not load dashboards',+ },+ ]+ : dashboardsLoading+ ? [{ label: 'Loading dashboards…', disabledReason: 'Loading' }]+ : pinnedDashboards.length+ ? pinnedDashboards.map((dashboard) => ({+ label: dashboard.name || 'Untitled dashboard',+ to: urls.dashboard(dashboard.id),+ }))+ : [{ label: 'No pinned dashboards', disabledReason: 'Pin a dashboard to show it here' }],+ },+ ]+ } else {+ items = [+ {+ label: 'Saved filters',+ items: [+ ...(savedFiltersLoading+ ? [{ label: 'Loading saved filters…', disabledReason: 'Loading' }]+ : loadSavedFiltersFailed+ ? [+ {+ label: 'Could not load saved filters. Reopen this menu to retry.',+ disabledReason: 'Could not load saved filters',+ },+ ]+ : savedFilters.results.map((filter) => ({+ label: filter.name || filter.derived_name || 'Unnamed',+ // Replay reads savedFilterId on mount, so a full navigation applies it even from Replay home.+ to: urls.absolute(+ combineUrl(urls.replay(ReplayTabs.Home), { savedFilterId: filter.short_id }).url+ ),+ disableClientSideRouting: true,+ }))),+ {+ label: 'All saved filters',+ to: `${urls.replay(ReplayTabs.Home)}?showFilters=true&filtersTab=saved`,+ },+ ],+ },+ {+ label: 'Collections',+ items: [+ ...(playlistsLoading+ ? [{ label: 'Loading collections…', disabledReason: 'Loading' }]+ : loadPlaylistsFailed+ ? [+ {+ label: 'Could not load collections. Reopen this menu to retry.',+ disabledReason: 'Could not load collections',+ },+ ]+ : playlists.results.map((playlist) => ({+ label: playlist.name || playlist.derived_name || 'Unnamed',+ to: urls.replayPlaylist(playlist.short_id),+ }))),+ { label: 'All collections', to: urls.replay(ReplayTabs.Playlists) },+ ],+ },+ { label: 'All recordings', to: urls.replay(ReplayTabs.Home) },+ ]+ }++ useOnMountEffect(() => {+ if (product === 'Dashboards') {+ if (loadDashboardsFailed) {+ loadDashboards()+ } else {+ loadDashboardsIfNeeded()+ }+ } else if (product === 'Session replay') {+ if (!savedFiltersLoading) {+ loadSavedFilters()+ }+ if (!playlistsLoading && loadPlaylistsFailed) {+ loadPlaylists()+ }+ }+ })++ return <LemonMenuOverlay items={items} />+}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsxnew file mode 100644index 000000000000..6b47172b4d91--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx@@ -0,0 +1,78 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import { cleanup, fireEvent, render, waitFor } from '@testing-library/react'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'+import { AccessControlLevel, AccessControlResourceType, TeamType } from '~/types'++import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { NavAppRow } from './NavAppRow'++const defaultAccess = Object.fromEntries(+ Object.values(AccessControlResourceType).map((type) => [type, AccessControlLevel.Editor])+) as Record<AccessControlResourceType, AccessControlLevel>++describe('NavAppRow', () => {+ beforeEach(() => {+ useMocks({ get: { '/api/environments/:team_id/file_system_shortcut/': { results: [] } } })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, conversations_enabled: true } as TeamType)+ window.POSTHOG_APP_CONTEXT = {+ ...window.POSTHOG_APP_CONTEXT!,+ effective_resource_access_control: defaultAccess,+ }+ })++ afterEach(cleanup)++ it('disables navigation and starring when access to a product is denied', () => {+ window.POSTHOG_APP_CONTEXT = {+ ...window.POSTHOG_APP_CONTEXT!,+ effective_resource_access_control: { ...defaultAccess, feature_flag: AccessControlLevel.None },+ }+ const { container, getByLabelText } = render(+ <NavAppRow+ item={{+ path: 'Feature flags',+ iconType: 'feature_flag',+ href: '/feature_flags',+ sceneKey: 'FeatureFlags',+ }}+ />+ )+ const row = container.querySelector<HTMLButtonElement>('[data-attr="nav-apps-item"]')+ expect(row?.disabled).toBe(true)+ expect(row?.hasAttribute('href')).toBe(false)+ expect(getByLabelText('Open Feature flags menu').getAttribute('aria-disabled')).toBe('true')+ })++ it('adds and removes a star through the existing shortcut API', async () => {+ const create = jest.fn(() => [+ 201,+ { id: 'star-test', path: 'Feature flags', type: 'feature_flag', href: '/feature_flags' },+ ])+ const remove = jest.fn(() => [204])+ useMocks({+ post: { '/api/environments/:team_id/file_system_shortcut/': create },+ delete: { '/api/environments/:team_id/file_system_shortcut/star-test/': remove },+ })+ const { getByLabelText, getByText, findByText } = render(+ <NavAppRow+ item={{ path: 'Feature flags', type: 'feature_flag', iconType: 'feature_flag', href: '/feature_flags' }}+ />+ )+ await waitFor(() => expect(projectTreeDataLogic.values.shortcutDataLoading).toBe(false))+ fireEvent.click(getByLabelText('Open Feature flags menu'))+ const add = await findByText('Add to starred')+ fireEvent.click(add)+ fireEvent.click(add)+ await waitFor(() => expect(projectTreeDataLogic.values.shortcutData).toHaveLength(1))+ expect(create).toHaveBeenCalledTimes(1)+ fireEvent.click(getByLabelText('Open Feature flags menu'))+ fireEvent.click(await findByText('Remove from starred'))+ await waitFor(() => expect(projectTreeDataLogic.values.shortcutData).toHaveLength(0))+ expect(remove).toHaveBeenCalledTimes(1)+ fireEvent.click(getByLabelText('Open Feature flags menu'))+ expect(getByText('Add to starred')).toBeTruthy()+ })+})diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsxnew file mode 100644index 000000000000..a7b172005611--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx@@ -0,0 +1,147 @@+import { useActions, useValues } from 'kea'+import { router } from 'kea-router'++import { IconChevronDown, IconEllipsis, IconGear, IconPlusSmall, IconStar, IconStarFilled } from '@posthog/icons'+import { LemonButton, LemonMenu, LemonTag } from '@posthog/lemon-ui'++import { LemonMenuItems } from 'lib/lemon-ui/LemonMenu'+import { Link } from 'lib/lemon-ui/Link'+import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'+import { urls } from 'scenes/urls'++import { navigationLogic } from '~/layout/navigation/navigationLogic'+import { uiCustomizationLogic } from '~/layout/uiCustomizationLogic'+import { FileSystemEntry, FileSystemIconType, FileSystemImport } from '~/queries/schema/schema-general'++import { panelLayoutLogic } from '../../panelLayoutLogic'+import { getCustomIcon } from '../../ProjectTree/customIconRegistry'+import { ProductIconWrapper, iconForType } from '../../ProjectTree/defaultTree'+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { joinPath, splitPath } from '../../ProjectTree/utils'+import { appsItemName } from './appsCatalog'+import { NavAppMenu } from './NavAppMenu'++export function NavAppRow({ item }: { item: FileSystemImport }): JSX.Element {+ const { pathname } = useValues(panelLayoutLogic)+ const { shortcutData, shortcutDataLoading } = useValues(projectTreeDataLogic)+ const { addShortcutItem, deleteShortcut } = useActions(projectTreeDataLogic)+ const { reportNavItemClicked } = useActions(eventUsageLogic)+ const { showConfigureHomeModal } = useActions(navigationLogic)+ const { uiCustomizationEnabled } = useValues(uiCustomizationLogic)+ const label = appsItemName(item)+ const shortcutPath = joinPath([splitPath(item.path).pop() ?? 'Unnamed'])+ const shortcut = shortcutData.find((entry) => entry.type !== 'folder' && entry.path === shortcutPath)+ const currentPath = removeProjectIdIfPresent(pathname)+ const href = item.href ?? ''+ const active =+ currentPath === href ||+ (href !== urls.projectRoot() && currentPath.startsWith(`${href}/`)) ||+ (href === urls.projectRoot() && currentPath === urls.projectHomepage()) ||+ (item.path === 'Session replay' && currentPath.startsWith('/replay/'))+ const disabledReason = getProductAccessDisabledReason(item)+ const CustomIcon = getCustomIcon(item.type)+ const iconType = item.iconType ?? (item.type as FileSystemIconType | undefined)++ const hasProductMenu = ['Product analytics', 'Dashboards', 'Session replay'].includes(item.path)+ const menuItems: LemonMenuItems = [+ ...(hasProductMenu ? [{ label: () => <NavAppMenu product={item.path} /> }] : []),+ ...(item.path === 'Home'+ ? [+ {+ items: [+ {+ label: 'Configure home',+ icon: <IconGear />,+ 'data-attr': 'nav-configure-home',+ onClick: () => {+ if (uiCustomizationEnabled) {+ router.actions.push(urls.settings('user-navigation', 'homepage'))+ } else {+ showConfigureHomeModal()+ }+ },+ },+ ],+ },+ ]+ : []),+ {+ items: [+ {+ label: shortcut ? 'Remove from starred' : 'Add to starred',+ icon: shortcut ? <IconStarFilled /> : <IconStar />,+ 'data-attr': 'nav-apps-star',+ disabledReason: disabledReason || (shortcutDataLoading ? 'Updating starred items' : undefined),+ onClick: () => (shortcut ? deleteShortcut(shortcut.id) : addShortcutItem(item as FileSystemEntry)),+ },+ ],+ },+ ]++ return (+ <div className="group/app-row relative flex items-center gap-px min-w-0">+ <Link+ to={disabledReason ? undefined : href}+ disabledReason={disabledReason}+ buttonProps={{+ menuItem: true,+ active,+ disabled: !!disabledReason,+ className:+ 'flex-1 min-w-0 -outline-offset-2 group-hover/app-row:pr-7 group-focus-within/app-row:pr-7',+ }}+ data-attr="nav-apps-item"+ tooltip={label}+ tooltipPlacement="right"+ onClick={() => reportNavItemClicked(item.path, 'tools')}+ >+ <span className="size-4 shrink-0">+ {CustomIcon ? (+ <ProductIconWrapper type={iconType} colorOverride={item.iconColor}>+ <CustomIcon />+ </ProductIconWrapper>+ ) : (+ iconForType(iconType, item.iconColor)+ )}+ </span>+ <span className="flex-1 truncate">{label}</span>+ {item.tags?.[0] && (+ <LemonTag type={item.tags[0] === 'alpha' ? 'completion' : 'warning'} size="small">+ {item.tags[0]}+ </LemonTag>+ )}+ </Link>+ <LemonMenu placement="right-start" items={menuItems}>+ <LemonButton+ size="xsmall"+ className="absolute right-0 opacity-0 group-hover/app-row:opacity-100 group-focus-within/app-row:opacity-100"+ icon={+ hasProductMenu ? (+ item.path === 'Product analytics' ? (+ <IconPlusSmall />+ ) : (+ <IconChevronDown />+ )+ ) : (+ <IconEllipsis />+ )+ }+ tooltip={`Open ${label} menu`}+ aria-label={`Open ${label} menu`}+ disabledReason={disabledReason}+ data-attr={+ item.path === 'Product analytics'+ ? 'flat-nav-tool-menu-insight'+ : item.path === 'Dashboards'+ ? 'flat-nav-tool-menu-dashboards'+ : item.path === 'Session replay'+ ? 'flat-nav-tool-menu-session-replay'+ : 'nav-apps-menu'+ }+ />+ </LemonMenu>+ </div>+ )+}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsxnew file mode 100644index 000000000000..3ab1b12105f1--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx@@ -0,0 +1,74 @@+import { useActions, useValues } from 'kea'++import { LemonInput, Spinner } from '@posthog/lemon-ui'++import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'++import { ProjectTree } from '../../ProjectTree/ProjectTree'+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'+import { NavAppRow } from './NavAppRow'+import { APPS_STARRED_TREE_KEY, navAppsTabLogic } from './navAppsTabLogic'++export function NavTabApps(): JSX.Element {+ const { search, groupedItems } = useValues(navAppsTabLogic)+ const { setSearch } = useActions(navAppsTabLogic)+ const { shortcutDataHasLoaded } = useValues(projectTreeDataLogic)+ const { fullFileSystemFiltered: starredApps } = useValues(+ projectTreeLogic({ key: APPS_STARRED_TREE_KEY, root: 'shortcuts://', shortcutScope: 'apps' })+ )++ return (+ <div className="flex flex-col h-full min-h-0 group/colorful-product-icons colorful-product-icons-true">+ <div className="p-1">+ <LemonInput+ type="search"+ size="small"+ className="min-h-[30px]"+ placeholder="Search apps"+ aria-label="Search apps"+ value={search}+ onChange={setSearch}+ fullWidth+ data-attr="nav-apps-search"+ />+ </div>+ <ScrollableShadows+ direction="vertical"+ className="flex-1 min-h-0"+ innerClassName="px-1 pb-2"+ styledScrollbars+ >+ <div className="px-2 pt-1 pb-1">+ <span className="text-xs font-semibold text-secondary">Starred</span>+ </div>+ {!shortcutDataHasLoaded ? (+ <Spinner className="m-2" />+ ) : starredApps.length > 0 ? (+ <ProjectTree+ root="shortcuts://"+ shortcutScope="apps"+ logicKey={APPS_STARRED_TREE_KEY}+ onlyTree+ showShortcutHelp={false}+ />+ ) : (+ <p className="text-xs text-tertiary px-2 py-1 mb-0">Star apps to keep them here.</p>+ )}+ {groupedItems.map((group) => (+ <section key={group.label} aria-label={group.label}>+ <h3 className="px-2 pt-3 pb-1 mb-0 text-xs font-semibold text-secondary">{group.label}</h3>+ <div className="flex flex-col gap-px">+ {group.items.map((item) => (+ <NavAppRow key={`${item.path}-${item.href}`} item={item} />+ ))}+ </div>+ </section>+ ))}+ {groupedItems.length === 0 && (+ <p className="text-xs text-tertiary px-2 py-2">No apps found. Try a different search.</p>+ )}+ </ScrollableShadows>+ </div>+ )+}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabFiles.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavTabFiles.tsxnew file mode 100644index 000000000000..1ac6f35ed277--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabFiles.tsx@@ -0,0 +1,60 @@+import { useValues } from 'kea'++import { Spinner } from '@posthog/lemon-ui'++import { panelLayoutLogic } from '../../panelLayoutLogic'+import { ProjectTree } from '../../ProjectTree/ProjectTree'+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'+import { FlatNavRecents } from './flat-nav/FlatNavRecents'++export function NavTabFiles(): JSX.Element {+ const { navExperimentActiveTab } = useValues(panelLayoutLogic)+ const { shortcutDataHasLoaded } = useValues(projectTreeDataLogic)+ const { fullFileSystemFiltered: starredFiles } = useValues(+ projectTreeLogic({ key: 'navbar-files-starred', root: 'shortcuts://', shortcutScope: 'files' })+ )+ return (+ <div className="flex flex-col h-full min-h-0">+ <div className="flex-1 min-h-0">+ <ProjectTree+ panelName="files"+ root="project://"+ logicKey="navbar-files"+ searchPlaceholder="Search files"+ showRecents+ layout="inline"+ beforeTree={+ <>+ <div className="px-1 pb-2">+ <div className="px-2 pt-1 pb-1">+ <span className="text-xs font-semibold text-secondary">Starred</span>+ </div>+ {!shortcutDataHasLoaded ? (+ <Spinner className="m-2" />+ ) : starredFiles.length > 0 ? (+ <ProjectTree+ root="shortcuts://"+ shortcutScope="files"+ logicKey="navbar-files-starred"+ onlyTree+ showShortcutHelp={false}+ />+ ) : (+ <p className="text-xs text-tertiary px-2 py-1 mb-0">+ Star files or folders to keep them here.+ </p>+ )}+ </div>+ <h3 className="px-3 pt-1 pb-1 mb-0 text-xs font-semibold text-secondary">Files</h3>+ </>+ }+ isActiveInPanel={navExperimentActiveTab === 'files'}+ />+ </div>+ <div className="max-h-1/3 overflow-y-auto px-2 border-t">+ <FlatNavRecents />+ </div>+ </div>+ )+}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/appsCatalog.ts b/frontend/src/layout/panel-layout/navbar/tabs/appsCatalog.tsnew file mode 100644index 000000000000..32241a0bbd75--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/appsCatalog.ts@@ -0,0 +1,50 @@+import { FileSystemImport } from '~/queries/schema/schema-general'++import { CATEGORY_ORDER, DATA_MANAGEMENT_PANEL_ORDER, splitPath, unescapePath } from '../../ProjectTree/utils'++export interface AppsItemGroup {+ label: string+ items: FileSystemImport[]+}++export function appsItemName(item: FileSystemImport): string {+ return item.displayLabel || unescapePath(splitPath(item.path).pop() ?? item.path)+}++const categoryOrder = [+ 'Project',+ ...new Set([+ ...CATEGORY_ORDER,+ ...Object.entries(DATA_MANAGEMENT_PANEL_ORDER)+ .sort(([, a], [, b]) => a - b)+ .map(([category]) => category),+ ]),+]++export function groupApps(items: FileSystemImport[], search: string): AppsItemGroup[] {+ const query = search.trim().toLowerCase()+ const groups = new Map<string, FileSystemImport[]>()+ for (const item of items) {+ if (query && !`${appsItemName(item)} ${item.path}`.toLowerCase().includes(query)) {+ continue+ }+ const category = item.category || 'Other'+ const group = groups.get(category) ?? []+ group.push(item)+ groups.set(category, group)+ }+ const orderOf = (category: string): number => {+ const index = categoryOrder.indexOf(category)+ return index === -1 ? categoryOrder.length : index+ }+ return [...groups.entries()]+ .sort(([a], [b]) => orderOf(a) - orderOf(b) || a.localeCompare(b))+ .map(([label, entries]) => ({+ label,+ items: entries.sort(+ (a, b) =>+ (a.visualOrder ?? Infinity) - (b.visualOrder ?? Infinity) ||+ appsItemName(a).localeCompare(appsItemName(b), undefined, { sensitivity: 'accent' })+ ),+ }))+}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavRecents.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavRecents.tsxindex 16727d67b7d0..6822bad204de 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavRecents.tsx+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavRecents.tsx@@ -1,5 +1,10 @@import { useActions, useValues } from 'kea'+import { useId } from 'react'+import { IconChevronDown } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'@@ -17,31 +22,53 @@ function getItemName(item: FileSystemEntry): string {}export function FlatNavRecents(): JSX.Element {- const { recentItems, recentItemsLoading } = useValues(navRecentsLogic)+ const { recentItems, recentItemsLoading, recentsCollapsed } = useValues(navRecentsLogic)+ const { setRecentsCollapsed } = useActions(navRecentsLogic)+ const recentItemsId = useId()+ const isSimpleSidepanelEnabled = useFeatureFlag('SIMPLE_SIDEPANEL')const { reportNavItemClicked } = useActions(eventUsageLogic)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}`}- onClick={() => reportNavItemClicked('recent', 'recents', item.type)}- />- ))- )}+ <FlatNavSection+ label="Recents"+ info="Items you viewed recently, most recent first."+ action={+ isSimpleSidepanelEnabled ? (+ <LemonButton+ size="xsmall"+ icon={<IconChevronDown className={recentsCollapsed ? 'rotate-180' : undefined} />}+ onClick={() => setRecentsCollapsed(!recentsCollapsed)}+ tooltip={recentsCollapsed ? 'Expand recents' : 'Collapse recents'}+ aria-label={recentsCollapsed ? 'Expand recents' : 'Collapse recents'}+ aria-expanded={!recentsCollapsed}+ aria-controls={recentItemsId}+ data-attr="nav-recents-toggle"+ />+ ) : undefined+ }+ >+ <div id={recentItemsId} hidden={isSimpleSidepanelEnabled && recentsCollapsed}>+ <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}`}+ onClick={() => reportNavItemClicked('recent', 'recents', item.type)}+ />+ ))+ )}+ </div></div></FlatNavSection>)diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.tsnew file mode 100644index 000000000000..e848e773503d--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts@@ -0,0 +1,103 @@+import { expectLogic } from 'kea-test-utils'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import { initKeaTests } from '~/test/init'+import { ActivityTab } from '~/types'++import { getDefaultTreeDataAndPeople, getDefaultTreeProducts } from '../../ProjectTree/defaultTree'+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'+import { appsItemName, groupApps } from './appsCatalog'+import { APPS_STARRED_TREE_KEY, navAppsTabLogic } from './navAppsTabLogic'++describe('navAppsTabLogic', () => {+ beforeEach(() => {+ initKeaTests()+ navAppsTabLogic.mount()+ })++ it.each([false, true])('retains every existing product and data destination with flags enabled: %s', (enabled) => {+ const registry = [...getDefaultTreeProducts(), ...getDefaultTreeDataAndPeople()]+ const flags = Object.fromEntries(registry.flatMap((item) => (item.flag ? [[item.flag, enabled]] : [])))+ featureFlagLogic.actions.setFeatureFlags([], flags)+ const expected = new Set([+ urls.projectRoot(),+ urls.activity(ActivityTab.ExploreEvents),+ ...registry.filter((item) => item.href && (!item.flag || enabled)).map((item) => item.href),+ ...projectTreeDataLogic.values.groupItems+ .filter((item) => item.href && (!item.flag || flags[item.flag]))+ .map((item) => item.href),+ ])+ const actual = navAppsTabLogic.values.groupedItems.flatMap((group) => group.items.map((item) => item.href))+ expect(new Set(actual)).toEqual(expected)+ expect(actual).toHaveLength(expected.size)+ })++ it('searches display names and preserves person ordering alongside dynamic groups', async () => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PRODUCT_AUTONOMY]: true })+ expect(navAppsTabLogic.values.groupedItems[0].items.map(appsItemName)).toEqual([+ 'Home',+ 'Self-driving',+ 'Activity',+ ])+ await expectLogic(navAppsTabLogic, () => navAppsTabLogic.actions.setSearch(' self-driving ')).toMatchValues({+ groupedItems: [+ {+ label: 'Project',+ items: [expect.objectContaining({ href: urls.inbox(), path: 'Inbox', tags: ['beta'] })],+ },+ ],+ })+ const groups = groupApps(+ [+ { path: 'Cohorts', category: 'People', href: '/cohorts', visualOrder: 20 },+ { path: 'Persons', category: 'People', href: '/persons', visualOrder: 10 },+ { path: 'group_0', displayLabel: 'Organizations', category: 'Groups', href: '/groups/0' },+ ],+ ''+ )+ expect(groups.find((group) => group.label === 'People')?.items.map(appsItemName)).toEqual([+ 'Persons',+ 'Cohorts',+ ])+ expect(+ groupApps(+ groups.flatMap((group) => group.items),+ 'organizations'+ )[0].items[0].href+ ).toEqual('/groups/0')+ })++ it('filters starred apps with the app search', async () => {+ const starredTree = projectTreeLogic({+ key: APPS_STARRED_TREE_KEY,+ root: 'shortcuts://',+ shortcutScope: 'apps',+ })+ await expectLogic(navAppsTabLogic, () => navAppsTabLogic.actions.setSearch('onboarding')).toDispatchActions([+ starredTree.actionTypes.setSearchTerm,+ ])+ expect(starredTree.values.searchTerm).toEqual('onboarding')+ })+ it.each([+ ['apps', ['Product analytics']],+ ['files', ['Overview', 'Research']],+ [undefined, ['Product analytics', 'Overview', 'Research']],+ ] as const)('keeps starred items in their own section: %s', (shortcutScope, expected) => {+ projectTreeDataLogic.actions.loadShortcutsSuccess([+ { id: 'app', path: 'Product analytics', type: 'product_analytics', href: '/insights' },+ { id: 'file', path: 'Overview', type: 'dashboard', ref: '1', href: '/dashboard/1' },+ { id: 'folder', path: 'Research', type: 'folder', ref: 'Research' },+ ])+ const tree = projectTreeLogic({ key: `scoped-${shortcutScope}`, root: 'shortcuts://', shortcutScope })+ tree.mount()+ expect(tree.values.fullFileSystemFiltered.map((item) => item.name)).toEqual(expected)+ tree.actions.setSearchTerm('Product analytics')+ expect(tree.values.fullFileSystemFiltered.map((item) => item.name)).toEqual(+ shortcutScope === 'files' ? [] : ['Product analytics']+ )+ })+})diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.tsnew file mode 100644index 000000000000..0d12f5237c07--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts@@ -0,0 +1,108 @@+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'++import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import { FileSystemImport } from '~/queries/schema/schema-general'+import { ActivityTab } from '~/types'++import { getDefaultTreeDataAndPeople, getDefaultTreeProducts } from '../../ProjectTree/defaultTree'+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'+import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'+import { AppsItemGroup, groupApps } from './appsCatalog'++export const APPS_STARRED_TREE_KEY = 'navbar-apps-starred'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navAppsTabLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ groupItems: FileSystemImport[] // projectTreeDataLogic+ allItems: FileSystemImport[]+ groupedItems: AppsItemGroup[]+ search: string+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navAppsTabLogicActions {+ setSearch: (search: string) => {+ search: string+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navAppsTabLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ allItems: (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]) => FileSystemImport[]+ groupedItems: (allItems: FileSystemImport[], search: string) => AppsItemGroup[]+ }+}++export type navAppsTabLogicType = MakeLogicType<+ navAppsTabLogicValues,+ navAppsTabLogicActions,+ Record<string, any>,+ navAppsTabLogicMeta+>++export const navAppsTabLogic = kea<navAppsTabLogicType>([+ path(['layout', 'panel-layout', 'navbar', 'tabs', 'navAppsTabLogic']),+ connect(() => ({+ values: [featureFlagLogic, ['featureFlags'], projectTreeDataLogic, ['groupItems']],+ logic: [projectTreeLogic({ key: APPS_STARRED_TREE_KEY, root: 'shortcuts://', shortcutScope: 'apps' })],+ })),+ actions({ setSearch: (search: string) => ({ search }) }),+ reducers({ search: ['', { setSearch: (_, { search }) => search }] }),+ selectors({+ allItems: [+ (s) => [s.featureFlags, s.groupItems],+ (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]): FileSystemImport[] => {+ const items: FileSystemImport[] = [+ { path: 'Home', category: 'Project', iconType: 'home', href: urls.projectRoot(), visualOrder: 0 },+ {+ path: 'Activity',+ category: 'Project',+ iconType: 'activity',+ href: urls.activity(ActivityTab.ExploreEvents),+ visualOrder: 2,+ },+ ...getDefaultTreeProducts().map(+ (item): FileSystemImport =>+ item.href === urls.inbox()+ ? {+ ...item,+ displayLabel: 'Self-driving',+ category: 'Project',+ visualOrder: 1,+ tags: ['beta'],+ }+ : item+ ),+ ...getDefaultTreeDataAndPeople(),+ ...groupItems,+ ]+ const destinations = new Map<string, FileSystemImport>()+ for (const item of items) {+ if (!item.href || (item.flag && !featureFlags[item.flag as keyof FeatureFlagsSet])) {+ continue+ }+ const existing = destinations.get(item.href)+ destinations.set(item.href, existing ? { ...item, ...existing } : item)+ }+ return [...destinations.values()]+ },+ ],+ groupedItems: [+ (s) => [s.allItems, s.search],+ (items: FileSystemImport[], search: string): AppsItemGroup[] => groupApps(items, search),+ ],+ }),+ listeners({+ setSearch: ({ search }) => {+ projectTreeLogic({+ key: APPS_STARRED_TREE_KEY,+ root: 'shortcuts://',+ shortcutScope: 'apps',+ }).actions.setSearchTerm(search)+ },+ }),+])diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navRecentsLogic.ts b/frontend/src/layout/panel-layout/navbar/tabs/navRecentsLogic.tsindex 2600ef3b6734..48829c25a3a6 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/navRecentsLogic.ts+++ b/frontend/src/layout/panel-layout/navbar/tabs/navRecentsLogic.ts@@ -1,4 +1,4 @@-import { MakeLogicType, connect, kea, path, selectors } from 'kea'+import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'import { recentItemsModel } from '~/models/recentItemsModel'import { FileSystemEntry } from '~/queries/schema/schema-general'@@ -11,6 +11,14 @@ export interface navRecentsLogicValues {recentsHasLoaded: boolean // recentItemsModelrecentItems: FileSystemEntry[]recentItemsLoading: boolean+ recentsCollapsed: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navRecentsLogicActions {+ setRecentsCollapsed: (collapsed: boolean) => {+ collapsed: boolean+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -21,13 +29,22 @@ export interface navRecentsLogicMeta {}}-export type navRecentsLogicType = MakeLogicType<navRecentsLogicValues, {}, Record<string, any>, navRecentsLogicMeta>+export type navRecentsLogicType = MakeLogicType<+ navRecentsLogicValues,+ navRecentsLogicActions,+ Record<string, any>,+ navRecentsLogicMeta+>export const navRecentsLogic = kea<navRecentsLogicType>([path(['layout', 'panel-layout', 'ai-first', 'tabs', 'navRecentsLogic']),connect(() => ({values: [recentItemsModel, ['recents as cachedRecents', 'recentsHasLoaded']],})),+ actions({ setRecentsCollapsed: (collapsed: boolean) => ({ collapsed }) }),+ reducers({+ recentsCollapsed: [false, { persist: true }, { setRecentsCollapsed: (_, { collapsed }) => collapsed }],+ }),selectors({recentItems: [(s) => [s.cachedRecents],diff --git a/frontend/src/layout/panel-layout/panelLayoutLogic.tsx b/frontend/src/layout/panel-layout/panelLayoutLogic.tsxindex fc483beeff0a..fc0370921847 100644--- a/frontend/src/layout/panel-layout/panelLayoutLogic.tsx+++ b/frontend/src/layout/panel-layout/panelLayoutLogic.tsx@@ -15,7 +15,7 @@ export type PanelLayoutNavIdentifier =| 'DataAndPeople'| 'Chat'| 'Notifications'-export type NavExperimentTab = 'home' | 'chat'+export type NavExperimentTab = 'home' | 'files' | 'chat'export type PanelLayoutMainContentRef = React.RefObject<HTMLElement> | nullexport const PANEL_LAYOUT_DEFAULT_WIDTH: number = 245export const PANEL_LAYOUT_MIN_WIDTH: number = 160diff --git a/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsx b/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsxindex 8e1e9c2c30e7..58d65d1cb9b8 100644--- a/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsx+++ b/frontend/src/lib/components/NavSearchButton/NavSearchButton.tsx@@ -6,16 +6,19 @@ import { keyBinds } from 'lib/components/Shortcuts/shortcuts'import posthog from 'lib/posthog-typed'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'-/** Icon-only search trigger, used in the collapsed nav where there is no room for the search bar. */export function NavSearchButton({toggleCommand,+ showShortcut = false,}: {toggleCommand: (source: CommandOpenSource) => void+ showShortcut?: boolean}): JSX.Element {return (<ButtonPrimitive- iconOnly- data-attr="nav-search"+ iconOnly={!showShortcut}+ className={showShortcut ? 'shrink-0' : undefined}+ aria-label="Search"+ data-attr={showShortcut ? 'nav-search-bar' : 'nav-search'}tooltip={<div className="flex items-center gap-2"><span>Search</span> <RenderKeybind keybind={[keyBinds.search]} />@@ -24,10 +27,11 @@ export function NavSearchButton({tooltipPlacement="right"onClick={() => {posthog.capture('nav search clicked')- toggleCommand('nav-search-button')+ toggleCommand(showShortcut ? 'nav-search-bar' : 'nav-search-button')}}><IconSearch className="size-4 shrink-0 text-secondary" />+ {showShortcut && <RenderKeybind keybind={[keyBinds.search]} />}</ButtonPrimitive>)}diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 3fc946e74001..d9f5781227b1 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -339,8 +339,6 @@ export const FEATURE_FLAGS = {GITHUB_WORKFLOW_TRIGGERS: 'github-workflow-triggers', // owner: #team-workflows-cdpGROUP_PROFILE_EXPERIMENT: 'group-profile-experiment', // owner: @arthurdedeus #team-customer-analyticsHEALTH_ASK_AI: 'health-ask-ai', // owner: @jordanm-posthog #team-web-analytics, gates the "Ask PostHog AI" buttons on the Health overview- // Disabling this for an org restores every event marked hidden_in_query_builders at once, in every- // picker. There is no per-event or per-picker granularity, so weigh that before marking a second event.HIDE_EVENTS_IN_QUERY_BUILDERS: 'hide-events-in-query-builders', // owner: #team-feature-flags, kill switch for hiding events marked hidden_in_query_builders from insight/cohort/destination pickersHOGQL_WAREHOUSE_ACCESS_CONTROL: 'hogql-warehouse-access-control', // owner: @a-lider #team-platform-features, gates per-object access control for warehouse tables and viewsIDENTITY_MATCHING: 'identity-matching', // owner: @fercgomes #team-growth, gates new identity matching scene on marketing analytics@@ -500,6 +498,7 @@ export const FEATURE_FLAGS = {SHOW_REFERRER_FAVICON: 'show-referrer-favicon', // owner: @jordanm-posthog #team-web-analyticsSHOW_REPLAY_FILTERS_FEEDBACK_BUTTON: 'show-replay-filters-feedback-button', // owner: @ksvat #team-replaySIGNUP_AA_TEST_4_WAY: 'signup-aa-test-4-way', // owner: @andehen #team-experiments multivariate=control,test-1,test-2,test-3+ SIMPLE_SIDEPANEL: 'simple-sidepanel',SLACK_DWH: 'slack-dwh', // owner: @MarconLP #team-warehouse-sourcesSLACK_WORKFLOW_TRIGGERS: 'slack-workflow-triggers', // owner: #team-workflows-cdpSQL_EDITOR_BI_MODE: 'sql-editor-bi-mode', // owner: @mariusandra #team-data-tools