Skip to content

: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.

fix(today): merge the phone header and the scene title (#112984)

posthog[bot]001daf6c4730
diff --git a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx
index f4f7140f4598..30f6c99f94c8 100644
--- a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx
+++ b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx
@@ -10,6 +10,7 @@ import { ReleaseStageTag } from 'lib/components/ReleaseStageTag/ReleaseStageTag'
import { sceneLogic } from 'scenes/sceneLogic'
import { breadcrumbsLogic } from '~/layout/navigation/Breadcrumbs/breadcrumbsLogic'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { sceneLayoutLogic } from '../sceneLayoutLogic'
import { QuillSceneHeader } from './QuillSceneHeader'
@@ -50,13 +51,17 @@ export function QuillSceneTitleSection({
const { activeSceneId } = useValues(sceneLogic)
const { showDescription } = useValues(sceneLayoutLogic)
const { toggleShowDescription } = useActions(sceneLayoutLogic)
+ const { phoneHeaderShown } = useValues(todayShellLogic)
+ // The phone header shows the title, so this row keeps only the actions. A new resource keeps its name field.
+ const titleInPhoneHeader = phoneHeaderShown && !forceEdit
const releaseStageSceneId = sceneId ?? activeSceneId
const releaseStageProduct = useMemo(
() => releaseStageProductForScene(releaseStageSceneId, name),
[releaseStageSceneId, name]
)
const hasDescription = description != null && (description || canEdit)
- const descriptionShown = hasDescription && (descriptionAlwaysVisible || showDescription || forceEdit)
+ const descriptionShown =
+ hasDescription && (descriptionAlwaysVisible || (showDescription && !titleInPhoneHeader) || forceEdit)
return (
<>
@@ -64,16 +69,18 @@ export function QuillSceneTitleSection({
className={cn(
'z-30 bg-[var(--scene-layout-background)] @2xl/main-content:sticky -top-[calc(var(--spacing)*4)]',
!noPadding && '-mx-4 -mt-4',
+ titleInPhoneHeader && 'hidden has-[>div>*]:flex',
className
)}
back={
- forceBackTo || breadcrumbs.length > 2 ? (
+ !titleInPhoneHeader && (forceBackTo || breadcrumbs.length > 2) ? (
<SceneBreadcrumbBackButton forceBackTo={forceBackTo} />
) : undefined
}
- icon={name !== null ? sceneResourceIcon(resourceType) : undefined}
+ icon={name !== null && !titleInPhoneHeader ? sceneResourceIcon(resourceType) : undefined}
title={
- name !== null && (
+ name !== null &&
+ !titleInPhoneHeader && (
<QuillSceneName
name={name}
isLoading={isLoading}
diff --git a/frontend/src/layout/today/TodayPhoneHeader.tsx b/frontend/src/layout/today/TodayPhoneHeader.tsx
index dce4cdc83b42..c54a3db24c8d 100644
--- a/frontend/src/layout/today/TodayPhoneHeader.tsx
+++ b/frontend/src/layout/today/TodayPhoneHeader.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { useEffect, useState } from 'react'
-import { IconChevronLeft, IconSidePanel } from '@posthog/icons'
+import { IconChevronLeft, IconSidePanel, IconSidebarOpen } from '@posthog/icons'
import { Button, Text } from '@posthog/quill'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
@@ -11,13 +11,11 @@ import { SidePanelTab } from '~/types'
import { todayShellLogic } from './todayShellLogic'
-const TITLE_SCROLL_THRESHOLD = 56
-
export function TodayPhoneHeader(): JSX.Element {
const { sceneBreadcrumbs } = useValues(breadcrumbsLogic)
const { scenePanelIsPresent } = useValues(sceneLayoutLogic)
- const { onAiPage } = useValues(todayShellLogic)
- const { goBackOnPhone } = useActions(todayShellLogic)
+ const { onAiPage, phoneCanGoBack } = useValues(todayShellLogic)
+ const { goBackOnPhone, setMobileSidebarOpen } = useActions(todayShellLogic)
const { openSidePanel } = useActions(sidePanelStateLogic)
const [scrolled, setScrolled] = useState(false)
const title = [...sceneBreadcrumbs].reverse().find((breadcrumb) => !!breadcrumb.name)?.name
@@ -27,7 +25,7 @@ export function TodayPhoneHeader(): JSX.Element {
if (!main) {
return
}
- const onScroll = (): void => setScrolled(main.scrollTop > TITLE_SCROLL_THRESHOLD)
+ const onScroll = (): void => setScrolled(main.scrollTop > 0)
onScroll()
main.addEventListener('scroll', onScroll, { passive: true })
return () => main.removeEventListener('scroll', onScroll)
@@ -35,15 +33,21 @@ export function TodayPhoneHeader(): JSX.Element {
return (
<header className="TodayPhoneHeader" data-scrolled={scrolled} data-quill>
- <Button size="icon-lg" aria-label="Back" data-attr="today-phone-back" onClick={goBackOnPhone}>
- <IconChevronLeft />
- </Button>
- <Text
- render={<span />}
- weight="semibold"
- className="TodayPhoneHeader__title min-w-0 flex-1 truncate"
- aria-hidden={!scrolled}
- >
+ {phoneCanGoBack ? (
+ <Button size="icon-lg" aria-label="Back" data-attr="today-phone-back" onClick={goBackOnPhone}>
+ <IconChevronLeft />
+ </Button>
+ ) : (
+ <Button
+ size="icon-lg"
+ aria-label="Open sidebar"
+ data-attr="today-phone-sidebar"
+ onClick={() => setMobileSidebarOpen(true)}
+ >
+ <IconSidebarOpen />
+ </Button>
+ )}
+ <Text render={<span />} weight="semibold" className="min-w-0 flex-1 truncate">
{title}
</Text>
{!onAiPage && (
diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scss
index 20cff3a5caac..6fd55cf45033 100644
--- a/frontend/src/layout/today/TodayShell.scss
+++ b/frontend/src/layout/today/TodayShell.scss
@@ -96,19 +96,6 @@
}
}
-.TodayPhoneHeader__title {
- opacity: 0;
- transition:
- opacity 200ms var(--today-ease),
- transform 200ms var(--today-ease);
- transform: translateY(4px);
-
- .TodayPhoneHeader[data-scrolled='true'] & {
- opacity: 1;
- transform: none;
- }
-}
-
.TodayShell--phone {
display: contents;
}
@@ -183,8 +170,7 @@ body.has-today-phone-layout .Toastify__toast-container--bottom-right {
.TodayShell__scrim,
.TodayShell__drawer,
.TodayShell__page,
- .TodayPhoneHeader,
- .TodayPhoneHeader__title {
+ .TodayPhoneHeader {
transition: none;
}
}
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
index 0589f15e3bdb..30a6f8389ef6 100644
--- a/frontend/src/layout/today/todayShellLogic.test.ts
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -166,14 +166,17 @@ describe('todayShellLogic', () => {
logic.actions.pickPane('tools')
router.actions.push('/project/1/sql')
+ expect(logic.values.phoneCanGoBack).toBe(false)
router.actions.push('/project/1/sql?open_query=abc')
router.actions.push('/project/1/insights/abc')
expect(logic.values.sidebarVisible).toBe(false)
+ expect(logic.values.phoneCanGoBack).toBe(true)
logic.actions.goBackOnPhone()
expect(router.values.location.pathname).toBe('/project/1/sql')
expect(router.values.location.search).toBe('?open_query=abc')
expect(logic.values.sidebarVisible).toBe(false)
+ expect(logic.values.phoneCanGoBack).toBe(false)
logic.actions.goBackOnPhone()
expect(logic.values.sidebarVisible).toBe(true)
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
index 5c429fbf4eb3..b55122ad5636 100644
--- a/frontend/src/layout/today/todayShellLogic.ts
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -106,7 +106,9 @@ export interface todayShellLogicValues {
leftNavWidth: number
mobileSidebarOpen: boolean
onAiPage: boolean
+ phoneCanGoBack: boolean
phoneHeaderHidden: boolean
+ phoneHeaderShown: boolean
phoneLayout: boolean
phonePages: TodayPhonePage[]
pickedPane: TodayRailPane | null
@@ -187,6 +189,8 @@ export interface todayShellLogicMeta {
todayRailEnabled: boolean,
phoneLayout: boolean
) => boolean
+ phoneHeaderShown: (todayRailEnabled: boolean, phoneLayout: boolean, phoneHeaderHidden: boolean) => boolean
+ phoneCanGoBack: (phonePages: TodayPhonePage[]) => boolean
}
}
@@ -290,6 +294,13 @@ export const todayShellLogic = kea<todayShellLogicType>([
phoneLayout: boolean
): boolean => todayRailEnabled && phoneLayout && onAiPage && !!searchParams.task,
],
+ // The phone header shows the scene title, so the scene title row leaves it out.
+ phoneHeaderShown: [
+ (s) => [s.todayRailEnabled, s.phoneLayout, s.phoneHeaderHidden],
+ (todayRailEnabled: boolean, phoneLayout: boolean, phoneHeaderHidden: boolean): boolean =>
+ todayRailEnabled && phoneLayout && !phoneHeaderHidden,
+ ],
+ phoneCanGoBack: [(s) => [s.phonePages], (phonePages: TodayPhonePage[]): boolean => phonePages.length > 1],
}),
subscriptions(({ actions }) => ({
mobileLayout: () => actions.setMobileSidebarOpen(false),
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
index 7a42324d8430..b43481c2b786 100644
--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx
+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
@@ -995,6 +995,11 @@ export const PhoneWidthMorePane: Story = {
},
}
+// A root page: the phone header shows the title and a sidebar button, and the scene title row keeps only its actions.
+export const PhoneWidthListScene: Story = {
+ parameters: { pageUrl: urls.featureFlags(), testOptions: { viewport: { width: 390, height: 844 } } },
+}
+
// The card opens on hover, which a static story can't hold, so these render its contents in the same frame.
const noop = (): void => {}