: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(today): scene menus in the title row (#116205)
Adam Leith734abf36abbc
diff --git a/frontend/src/layout/scenes/AGENTS.md b/frontend/src/layout/scenes/AGENTS.mdindex a6e90603d5b5..90b6ba2682f9 100644--- a/frontend/src/layout/scenes/AGENTS.md+++ b/frontend/src/layout/scenes/AGENTS.md@@ -8,7 +8,7 @@ This directory owns the **scene action surfaces**:- **`SceneMenuBar`** (`components/SceneMenuBar.tsx`): the Mac-style menu bar above `<SceneTitleSection>`that consolidates those actions into File / Edit / View / Metadata / Staff only menus. This is the**new** action surface, gated behind the `SCENE_MENU_BAR` feature flag. Under the `today-rail-nav` flag- the bar moves itself below the title row, so scenes still render it above `<SceneTitleSection>`.+ the menus move into the title row after the scene name, so scenes still render it above `<SceneTitleSection>`.We are mid-migration (`ScenePanel` to `SceneMenuBar`). Until the flag ships everywhere, **both surfacesmust stay in sync**.diff --git a/frontend/src/layout/scenes/components/QuillSceneStaticName.tsx b/frontend/src/layout/scenes/components/QuillSceneStaticName.tsxnew file mode 100644index 000000000000..e45e68f9d2b6--- /dev/null+++ b/frontend/src/layout/scenes/components/QuillSceneStaticName.tsx@@ -0,0 +1,49 @@+import type { ReactNode } from 'react'++import { Button, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quill'++export interface QuillSceneStaticNameProps {+ name: ReactNode+ icon?: ReactNode+ /** Shown as the name's tooltip instead of a line under the title. */+ description?: ReactNode+ className?: string+}++/**+ * A scene name nobody can rename, drawn like the trail's crumbs so the whole trail reads as one line. The scene+ * description moves into its tooltip. `QuillSceneTrail` renders it as its last crumb and owns its offsets.+ */+export function QuillSceneStaticName({ name, icon, description, className }: QuillSceneStaticNameProps): JSX.Element {+ const crumb = (+ <Button+ nativeButton={false}+ render={<h1 />}+ // Focusable only to reach the tooltip, so keyboard users can read the description too.+ tabIndex={description ? 0 : undefined}+ className={cn(+ 'm-0 min-w-0 cursor-default text-foreground hover:bg-transparent active:[translate:none]',+ className+ )}+ data-attr="scene-name"+ >+ {icon && (+ <span className="flex size-4 shrink-0 items-center justify-center [&_svg]:size-4" aria-hidden>+ {icon}+ </span>+ )}+ <span className="truncate">{name}</span>+ </Button>+ )++ if (!description) {+ return crumb+ }++ return (+ <Tooltip disableHoverablePopup>+ <TooltipTrigger delay={300} render={crumb} />+ <TooltipContent className="max-w-80">{description}</TooltipContent>+ </Tooltip>+ )+}diff --git a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsxindex b27278a73d53..040f9f9af573 100644--- a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx+++ b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx@@ -18,7 +18,7 @@ import { QuillSceneHeader } from './QuillSceneHeader'import { QuillSceneName } from './QuillSceneName'import { QuillSceneTrail } from './QuillSceneTrail'import { SceneDescription } from './SceneDescription'-import { useRegisterSceneMenuBarSlot, useSceneMenuBarSlotMarginTop } from './SceneMenuBarSlotProvider'+import { useRegisterSceneMenuBarSlot, useSceneMenuBarSlotFilled } from './SceneMenuBarSlotProvider'import { sceneResourceIcon } from './sceneResourceIcon'import { SceneTitlePanelButton } from './SceneTitlePanelButton'import type { SceneMainTitleProps } from './SceneTitleSection'@@ -62,15 +62,24 @@ export function QuillSceneTitleSection({() => releaseStageProductForScene(releaseStageSceneId, name),[releaseStageSceneId, name])+ const staticName = name !== null && !titleInPhoneHeader && !(onNameChange && canEdit) && !forceEdit && !isLoadingconst hasDescription = description != null && (description || canEdit)const descriptionShown =- hasDescription && (descriptionAlwaysVisible || (showDescription && !titleInPhoneHeader) || forceEdit)+ hasDescription &&+ (descriptionAlwaysVisible || (showDescription && !titleInPhoneHeader && !staticName) || forceEdit)const backTo = forceBackTo || (breadcrumbs.length > 2 ? breadcrumbs[breadcrumbs.length - 2] : undefined)const backPath = !titleInPhoneHeader && backTo && 'path' in backTo ? backTo.path : undefinedconst resourceIcon = name !== null && !titleInPhoneHeader ? sceneResourceIcon(resourceType) : undefined+ const nameSuffixes = (+ <>+ {releaseStageProduct && <ReleaseStageTag product={releaseStageProduct} />}+ {nameSuffix}+ </>+ )const [menuBarSlot, setMenuBarSlot] = useState<HTMLDivElement | null>(null)useRegisterSceneMenuBarSlot(menuBarSlot)- const menuBarSlotMarginTop = useSceneMenuBarSlotMarginTop(menuBarSlot)+ // The menu bar's Help menu carries the settings link, so the title shows its own only without a bar.+ const menuBarShown = useSceneMenuBarSlotFilled()return (<>@@ -81,7 +90,7 @@ export function QuillSceneTitleSection({titleInPhoneHeader && 'hidden has-[>div>*]:flex',className,// Last, so a caller's spacing cannot move the row. The sidebar toggle must sit on the same spot in- // every scene. The menu bar portals below the row, so callers that make room for it above need not.+ // every scene. The menu bar portals into the row, so callers that make room for it above need not.'px-4',!noPadding && '-mt-4')}@@ -90,60 +99,62 @@ export function QuillSceneTitleSection({lead={sidebarBreadcrumbShown && <TodaySidebarBreadcrumb />}parent={backTo && backPath ? { name: backTo.name, path: backPath } : undefined}icon={resourceIcon}+ current={staticName ? { name, description: description || undefined } : undefined}/>}title={- name !== null &&- !titleInPhoneHeader && (- <QuillSceneName- name={name}- isLoading={isLoading}- onChange={onNameChange}- canEdit={canEdit}- forceEdit={forceEdit}- renameDebounceMs={renameDebounceMs}- saveOnBlur={saveOnBlur}- onGenerateMetadata={onGenerateMetadata}- isGeneratingMetadata={isGeneratingMetadata}- suffix={- <>- {releaseStageProduct && <ReleaseStageTag product={releaseStageProduct} />}- {nameSuffix}- {hasDescription && !descriptionAlwaysVisible && (- <Button- variant="default"- size="icon-sm"- aria-label={showDescription ? 'Hide description' : 'Show description'}- onClick={toggleShowDescription}- data-attr={- showDescription- ? 'toggle-description-button-collapse'- : 'toggle-description-button-expand'- }- >- {showDescription || forceEdit ? <IconCollapse /> : <IconExpand />}- </Button>- )}- </>- }+ <>+ {staticName && nameSuffixes}+ {name !== null && !titleInPhoneHeader && !staticName && (+ <QuillSceneName+ name={name}+ isLoading={isLoading}+ onChange={onNameChange}+ canEdit={canEdit}+ forceEdit={forceEdit}+ renameDebounceMs={renameDebounceMs}+ saveOnBlur={saveOnBlur}+ onGenerateMetadata={onGenerateMetadata}+ isGeneratingMetadata={isGeneratingMetadata}+ suffix={+ <>+ {nameSuffixes}+ {hasDescription && !descriptionAlwaysVisible && (+ <Button+ variant="default"+ size="icon-sm"+ aria-label={showDescription ? 'Hide description' : 'Show description'}+ onClick={toggleShowDescription}+ data-attr={+ showDescription+ ? 'toggle-description-button-collapse'+ : 'toggle-description-button-expand'+ }+ >+ {showDescription || forceEdit ? <IconCollapse /> : <IconExpand />}+ </Button>+ )}+ </>+ }+ />+ )}+ {/* The scene menu bar portals in here, so its menus follow the name after a short divider. A narrow scene wraps+ the menus onto their own line, where the divider would lead the line, so it hides there. */}+ <div+ ref={setMenuBarSlot}+ className="flex min-w-0 items-center empty:hidden before:mx-1 before:h-4 before:w-px before:shrink-0 before:bg-[var(--border)] before:content-[''] @max-xl/main-content:before:hidden"/>- )+ </>}actions={<>{!hideProductSetupButton && <ProductSetupButton />}{actions}- <SceneTitleSettingsButton />+ {!menuBarShown && <SceneTitleSettingsButton />}<SceneTitlePanelButton maxToolProps={maxToolProps} maxButtonLabel={maxButtonLabel} /></>}/>- {/* The scene menu bar portals in here. It sits outside the sticky header, so it scrolls away. */}- <div- ref={setMenuBarSlot}- className={cn('empty:hidden', !noPadding && '-mx-4')}- style={{ marginTop: menuBarSlotMarginTop }}- />{descriptionShown && (<div className={cn('[&_svg]:size-6', noPadding && cn('pl-4 pr-2', className))}><SceneDescriptiondiff --git a/frontend/src/layout/scenes/components/QuillSceneTrail.tsx b/frontend/src/layout/scenes/components/QuillSceneTrail.tsxindex 6014906607a8..9704c65d29d6 100644--- a/frontend/src/layout/scenes/components/QuillSceneTrail.tsx+++ b/frontend/src/layout/scenes/components/QuillSceneTrail.tsx@@ -4,33 +4,45 @@ import { Button, cn } from '@posthog/quill'import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { QuillSceneStaticName } from './QuillSceneStaticName'+export interface QuillSceneTrailParent {name: ReactNodepath: string}// Every offset in the trail lives here. Each one cancels padding so the gaps read evenly and nothing moves when the-// trail changes shape: link buttons pad 8px, and `QuillSceneName`'s box pads its text by 7px (6px plus a 1px border).-const SLASH = 'shrink-0 text-muted-foreground'-const SLASH_AFTER_LINK = cn(SLASH, '-ms-1 me-1')+// trail changes shape: link buttons and the current crumb pad 8px, and `QuillSceneName`'s box pads its text by 7px+// (6px plus a 1px border).+const SLASH = 'shrink-0 text-subtle-foreground'+const SLASH_AFTER_LINK = cn(SLASH, 'me-1')const SLASH_BEFORE_NAME = cn(SLASH, '-ms-1 -me-[3px]')const TITLE_ICON = '-me-1.5 flex size-4 shrink-0 items-center justify-center text-sm [&_svg]:size-4'const LINK_ICON = '-me-[3px] flex size-4 shrink-0 items-center justify-center [&_svg]:size-4'+const CRUMB = '-ms-2'++export interface QuillSceneTrailCurrent {+ name: ReactNode+ description?: ReactNode+}export interface QuillSceneTrailProps {/** A crumb before the parent, such as the hidden sidebar's pane. It must render as a link-sized button. */lead?: ReactNodeparent?: QuillSceneTrailParenticon?: ReactNode+ /** The scene itself as the last crumb, for a name nobody can rename. Without it, an editable name follows the trail. */+ current?: QuillSceneTrailCurrent}-export function QuillSceneTrail({ lead, parent, icon }: QuillSceneTrailProps): JSX.Element {+export function QuillSceneTrail({ lead, parent, icon, current }: QuillSceneTrailProps): JSX.Element {return (<>{lead && (<>{lead}- <span className={SLASH_AFTER_LINK} aria-hidden>+ {/* The lead drops to an icon in a narrow scene, and a slash after a bare icon reads as noise. */}+ <span className={cn(SLASH_AFTER_LINK, '@max-xl/main-content:hidden')} aria-hidden>/</span></>@@ -49,17 +61,26 @@ export function QuillSceneTrail({ lead, parent, icon }: QuillSceneTrailProps): J)}<span className="truncate">{parent.name}</span></Button>- <span className={SLASH_BEFORE_NAME} aria-hidden>+ <span className={current ? SLASH_AFTER_LINK : SLASH_BEFORE_NAME} aria-hidden>/</span></>) : (- icon && (+ icon &&+ !current && (<span className={TITLE_ICON} aria-hidden>{icon}</span>))}+ {current && (+ <QuillSceneStaticName+ name={current.name}+ icon={parent ? undefined : icon}+ description={current.description}+ className={CRUMB}+ />+ )}</>)}diff --git a/frontend/src/layout/scenes/components/SceneMenuBar.tsx b/frontend/src/layout/scenes/components/SceneMenuBar.tsxindex d76192b3f30c..704a895b390e 100644--- a/frontend/src/layout/scenes/components/SceneMenuBar.tsx+++ b/frontend/src/layout/scenes/components/SceneMenuBar.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import { router } from 'kea-router'import posthog from 'posthog-js'import { Children, ComponentProps, MouseEvent, ReactNode, useContext, useEffect } from 'react'import { createPortal } from 'react-dom'@@ -37,7 +38,7 @@ import { todayShellLogic } from '~/layout/today/todayShellLogic'import { SidePanelTab } from '~/types'import { SceneContentContext } from './SceneContent'-import { useSceneMenuBarSlot } from './SceneMenuBarSlotProvider'+import { useFillSceneMenuBarSlot, useSceneMenuBarSlot } from './SceneMenuBarSlotProvider'import { getSceneSettingsUrl } from './sceneSettingsUrl'/**@@ -70,8 +71,9 @@ export function SceneMenuBar({ children, className }: SceneMenuBarProps): JSX.Elconst isPaddedLayout = PADDED_LAYOUTS.has(layout)const { todayRailEnabled } = useValues(todayShellLogic)const titleSlot = useSceneMenuBarSlot()- // Under the Today layout the bar sits below the scene title. A scene without a title keeps it inline.+ // Under the Today layout the menus sit in the title row after the scene name. A scene without a title keeps the bar.const slot = todayRailEnabled ? titleSlot : null+ useFillSceneMenuBarSlot(!!slot)// A skipped product empty state parks its "isn't receiving data yet" reminder here so it// sits just below the bar. Null for every other scene, so nothing extra renders.@@ -81,55 +83,74 @@ export function SceneMenuBar({ children, className }: SceneMenuBarProps): JSX.ElcaptureSceneMenuBar('scene menu bar shown')}, [])- const content = (- <>- <div- data-attr="scene-menu-bar"- data-scene-layout={layout}- className={cn(- 'scene-menu-bar px-0.5 py-0.5 border-b border-primary flex items-center justify-between',- // The title slot places the bar itself. These offsets only fit the bar inline at the scene top.- !slot && [- // Below `lg` the navigation toggle floats over the top-left corner of the scene.- 'max-lg:pl-10',- // Bleed past the scene container's padding so the bar feels full-width — only- // safe when the layout actually has padding to cancel. Unpadded layouts- // (app-raw, plain, etc.) would overflow.- isPaddedLayout && '-mx-4 -mt-4',- // When LemonTabs is the immediately preceding sibling it already bleeds with- // its own -mt-6, leaving the menu bar floating in the flex `gap-y-*`. Pull the- // bar up so they sit flush.- '[.LemonTabs+&]:-mt-6',- ],- className- )}- >- {/*+ const bar = (+ <div+ data-attr="scene-menu-bar"+ data-scene-layout={layout}+ className={cn(+ 'scene-menu-bar flex items-center',+ // The title slot places the menus itself. This chrome and these offsets only fit the bar at the scene top.+ !slot && [+ 'px-0.5 py-0.5 border-b border-primary justify-between',+ // Below `lg` the navigation toggle floats over the top-left corner of the scene.+ 'max-lg:pl-10',+ // Bleed past the scene container's padding so the bar feels full-width — only+ // safe when the layout actually has padding to cancel. Unpadded layouts+ // (app-raw, plain, etc.) would overflow.+ isPaddedLayout && '-mx-4 -mt-4',+ // When LemonTabs is the immediately preceding sibling it already bleeds with+ // its own -mt-6, leaving the menu bar floating in the flex `gap-y-*`. Pull the+ // bar up so they sit flush.+ '[.LemonTabs+&]:-mt-6',+ ],+ className+ )}+ >+ {/*Right-side cluster lives OUTSIDE <Menubar> so it doesn't pollute the Menubar'sCompositeRoot — that's what coordinates ArrowLeft/Right navigation andhover-to-switch between menus.*/}- <Menubar className="gap-0 border-0">- {children}- {todayRailEnabled && <SceneMenuBarHelpMenu />}- </Menubar>+ <Menubar className="gap-0 border-0">+ {children}+ {todayRailEnabled && <SceneMenuBarHelpMenu />}+ </Menubar>+ {!slot && (<Badge className={cn('hidden @[800px]:flex', todayRailEnabled && 'me-1')}>OS-like menu (alpha)</Badge>- {!todayRailEnabled && <SceneMenuBarRightLinks />}- </div>+ )}+ {!todayRailEnabled && <SceneMenuBarRightLinks />}+ </div>+ )++ return (+ <>+ {slot ? createPortal(bar, slot) : bar}{setupReminder}</>)-- return slot ? createPortal(content, slot) : content}/** The last menu, as in macOS. Every scene gets it, so scenes never add their own. */function SceneMenuBarHelpMenu(): JSX.Element {const { openSidePanel } = useActions(sidePanelStateLogic)+ const { productKey } = useContext(SceneContentContext)+ const settingsUrl = getSceneSettingsUrl(productKey)return (<SceneMenuBarMenu label="Help" dataAttr="scene-menu-bar-help">+ {settingsUrl && (+ <>+ <SceneMenuBarItem+ data-attr="scene-menu-bar-settings"+ onClick={() => router.actions.push(settingsUrl)}+ >+ <IconGear />+ Settings+ </SceneMenuBarItem>+ <SceneMenuBarSeparator />+ </>+ )}<SceneMenuBarItemdata-attr="scene-menu-bar-docs"onClick={() => window.open('https://posthog.com/docs', '_blank', 'noopener')}@@ -294,6 +315,8 @@ export function SceneMenuBarMenu({className={cn(// Override DropdownMenuContent's default `w-(--anchor-width)` so menus size to content.'w-auto min-w-max',+ // Items that render nothing can leave a separator at an edge or two in a row. Hide those.+ '[&_[role=separator]:is(:first-child,:last-child)]:hidden [&_[role=separator]+[role=separator]]:hidden',contentClassName)}>diff --git a/frontend/src/layout/scenes/components/SceneMenuBarSlotProvider.tsx b/frontend/src/layout/scenes/components/SceneMenuBarSlotProvider.tsxindex d69857b1d036..bc99e455bad0 100644--- a/frontend/src/layout/scenes/components/SceneMenuBarSlotProvider.tsx+++ b/frontend/src/layout/scenes/components/SceneMenuBarSlotProvider.tsx@@ -1,20 +1,33 @@import { PropsWithChildren, createContext, useContext, useLayoutEffect, useState } from 'react'/**- * Under the Today layout the scene title section exposes a slot below its header, and the scene menu bar portals into- * it. Scenes render the bar and the title as unrelated siblings, so each scene shares the slot element through this+ * Under the Today layout the scene title section exposes a slot after the scene name, and the scene menu bar portals+ * into it. Scenes render the bar and the title as unrelated siblings, so each scene shares the slot element through this* context.*/interface SceneMenuBarSlotContextValue {slot: HTMLElement | nullsetSlot: (slot: HTMLElement | null) => void+ /** Whether a menu bar fills the slot, so the title can leave out what the bar already offers. */+ filled: boolean+ setFilled: (filled: boolean) => void}-const SceneMenuBarSlotContext = createContext<SceneMenuBarSlotContextValue>({ slot: null, setSlot: () => {} })+const SceneMenuBarSlotContext = createContext<SceneMenuBarSlotContextValue>({+ slot: null,+ setSlot: () => {},+ filled: false,+ setFilled: () => {},+})export function SceneMenuBarSlotProvider({ children }: PropsWithChildren): JSX.Element {const [slot, setSlot] = useState<HTMLElement | null>(null)- return <SceneMenuBarSlotContext.Provider value={{ slot, setSlot }}>{children}</SceneMenuBarSlotContext.Provider>+ const [filled, setFilled] = useState(false)+ return (+ <SceneMenuBarSlotContext.Provider value={{ slot, setSlot, filled, setFilled }}>+ {children}+ </SceneMenuBarSlotContext.Provider>+ )}export function useRegisterSceneMenuBarSlot(element: HTMLElement | null): void {@@ -32,19 +45,17 @@ export function useSceneMenuBarSlot(): HTMLElement | null {return useContext(SceneMenuBarSlotContext).slot}-/**- * A negative top margin equal to the parent's flex gap, so the slot sits flush under the header. Scenes nest the title- * in parents with different gaps, so the gap is read from the DOM instead of assumed.- */-export function useSceneMenuBarSlotMarginTop(element: HTMLElement | null): number {- const [marginTop, setMarginTop] = useState(0)+export function useFillSceneMenuBarSlot(filling: boolean): void {+ const { setFilled } = useContext(SceneMenuBarSlotContext)useLayoutEffect(() => {- const parent = element?.parentElement- if (!parent) {+ if (!filling) {return}- const gap = parseFloat(getComputedStyle(parent).rowGap)- setMarginTop(Number.isFinite(gap) ? -gap : 0)- }, [element])- return marginTop+ setFilled(true)+ return () => setFilled(false)+ }, [filling, setFilled])+}++export function useSceneMenuBarSlotFilled(): boolean {+ return useContext(SceneMenuBarSlotContext).filled}diff --git a/frontend/src/layout/today/TodaySidebarBreadcrumb.tsx b/frontend/src/layout/today/TodaySidebarBreadcrumb.tsxindex 95a9e70bcfab..d400d95e0463 100644--- a/frontend/src/layout/today/TodaySidebarBreadcrumb.tsx+++ b/frontend/src/layout/today/TodaySidebarBreadcrumb.tsx@@ -12,7 +12,7 @@ export function TodaySidebarBreadcrumb(): JSX.Element {const { title } = TODAY_PANES[activePane]return (- <Tooltip>+ <Tooltip disableHoverablePopup><TooltipTriggerdelay={0}render={@@ -26,7 +26,8 @@ export function TodaySidebarBreadcrumb(): JSX.Element {>{/* The hide button centers this icon 7.5px from its edge. This button pads it by 8px, so pull it back. */}<IconShowSidebar className="-ms-[0.5px]" />- {title}+ {/* A narrow scene keeps only the icon, so the scene's own name has room. */}+ <span className="@max-xl/main-content:hidden">{title}</span></TooltipTrigger><TooltipContent>Show sidebardiff --git a/frontend/src/layout/today/TodaySidebarPinButton.tsx b/frontend/src/layout/today/TodaySidebarPinButton.tsxindex c33d35df1a33..e0f67bb4795a 100644--- a/frontend/src/layout/today/TodaySidebarPinButton.tsx+++ b/frontend/src/layout/today/TodaySidebarPinButton.tsx@@ -15,7 +15,7 @@ export function TodaySidebarPinButton(): JSX.Element | null {}return (- <Tooltip>+ <Tooltip disableHoverablePopup><TooltipTriggerdelay={0}render={diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.tsindex 771a2c840d50..5064dfe2bac5 100644--- a/frontend/src/layout/today/todayShellLogic.ts+++ b/frontend/src/layout/today/todayShellLogic.ts@@ -334,7 +334,10 @@ export const todayShellLogic = kea<todayShellLogicType>([phoneLayout: boolean,mobileLayout: boolean,sidebarVisible: boolean- ): boolean => todayRailEnabled && !phoneLayout && (mobileLayout || !sidebarVisible),+ ): boolean =>+ // Only a docked, hidden sidebar needs the crumb. Below the docking width the rail tile opens the+ // overlay sidebar, and the crumb would only crowd the title row.+ todayRailEnabled && !phoneLayout && !mobileLayout && !sidebarVisible,],}),subscriptions(({ actions }) => ({