:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mobile): route unpinned lists outside native tabs (#130611)
Chris Volzer2daa7cc9b9d7
diff --git a/products/mobile/app/errors/index.tsx b/products/mobile/app/(stack)/errors/index.tsxsimilarity index 100%rename from products/mobile/app/errors/index.tsxrename to products/mobile/app/(stack)/errors/index.tsxdiff --git a/products/mobile/app/replay/index.tsx b/products/mobile/app/(stack)/replay/index.tsxsimilarity index 100%rename from products/mobile/app/replay/index.tsxrename to products/mobile/app/(stack)/replay/index.tsxdiff --git a/products/mobile/docs/ARCHITECTURE.md b/products/mobile/docs/ARCHITECTURE.mdindex 73f660430ebe..f1d1b08ad4b8 100644--- a/products/mobile/docs/ARCHITECTURE.md+++ b/products/mobile/docs/ARCHITECTURE.md@@ -19,9 +19,9 @@ products/mobile/replay.tsx -> src/features/replay/ReplayListScreen chrome="tab" (a slot only while pinned)report/[id]/index.tsx -> src/features/report/ReportScreen (`/report/<id>`, as deep links and notifications open it)report/[id]/details.tsx -> src/features/report/details/ReportDetailsScreen (the full report)- errors/index.tsx -> src/features/errors/ErrorsListScreen chrome="stack" (pushed from the Views Browse row)+ (stack)/errors/index.tsx -> src/features/errors/ErrorsListScreen chrome="stack" (pushed from the Views Browse row)errors/[id].tsx -> src/features/errors/IssueScreen (`/errors/<id>`, `from` names the source for analytics)- replay/index.tsx -> src/features/replay/ReplayListScreen chrome="stack" (pushed from the Views Browse row)+ (stack)/replay/index.tsx -> src/features/replay/ReplayListScreen chrome="stack" (pushed from the Views Browse row)replay/[sessionId].tsx -> src/features/replay/SessionScreen (`/replay/<id>?t=<seconds>&source=<entry>`)chat.tsx -> src/features/chat/ChatSheet (transparent modal, draws its own sheet;no params starts a new chat, `taskId` and `runId` open one, `reportId` attaches a report)@@ -47,7 +47,8 @@ products/mobile/tabs/ TabsLayout (Inbox, Chats and Views tab navigator), BottomBar and TabsHeader (eachrendered once), tabHeaderStore (each tab's header state), NavMenu (the More menu),navPinStore (Errors and Sessions pinned to the nav pill, a device preference),- navPinRoutes (openNavTarget: the tab when pinned, a pushed screen when not),+ navPinRoutes (openNavTarget: the explicit (tabs) route when pinned, (stack) when not;+ both keep the public /errors and /replay URLs, without selecting a hidden native tab),navPinActions (pin change with toast and Undo), NavPinMenu (the Views row menu)inbox/ InboxScreen, InboxRow, InboxListFooter, hooks,prefetchPlan (prefetch window and queue), usePrefetchReportsdiff --git a/products/mobile/releases/requests/ota-1110-navigation.json b/products/mobile/releases/requests/ota-1110-navigation.jsonnew file mode 100644index 000000000000..cc36df526dd7--- /dev/null+++ b/products/mobile/releases/requests/ota-1110-navigation.json@@ -0,0 +1,8 @@+{+ "schemaVersion": 1,+ "id": "ota-1110-navigation",+ "kind": "ota",+ "runtimeVersion": "1.11.0",+ "previousRelease": "native-1110",+ "notes": "Fix opening Sessions and Errors from Views and returning with Back. Pinned lists stay in their navigation tabs. Both features remain controlled by their existing feature flags."+}diff --git a/products/mobile/src/features/tabs/MobileProductGate.test.tsx b/products/mobile/src/features/tabs/MobileProductGate.test.tsxindex 817c0001f080..5b59aa308f54 100644--- a/products/mobile/src/features/tabs/MobileProductGate.test.tsx+++ b/products/mobile/src/features/tabs/MobileProductGate.test.tsx@@ -2,12 +2,12 @@ import { renderRouter } from 'expo-router/testing-library'import type { ComponentType, ReactElement } from 'react'import { View } from 'react-native'import { FEATURE_FLAGS, type FeatureFlagKey, setFeatureFlags } from '@/lib/featureFlags'+import ErrorsRoute from '../../../app/(stack)/errors/index'+import ReplayRoute from '../../../app/(stack)/replay/index'import ErrorsTab from '../../../app/(tabs)/errors/index'import ReplayTab from '../../../app/(tabs)/replay/index'import IssueRoute from '../../../app/errors/[id]'-import ErrorsRoute from '../../../app/errors/index'import SessionRoute from '../../../app/replay/[sessionId]'-import ReplayRoute from '../../../app/replay/index'jest.mock('./TabScene', () => ({ TabScene: ({ children }: { children: React.ReactNode }) => children }))@@ -22,9 +22,9 @@ function Inbox(): ReactElement {}const ROUTES: { path: string; url: string; component: ComponentType; flag: FeatureFlagKey }[] = [- { path: 'errors/index', url: '/errors', component: ErrorsRoute, flag: FEATURE_FLAGS.errorTracking },+ { path: '(stack)/errors/index', url: '/errors', component: ErrorsRoute, flag: FEATURE_FLAGS.errorTracking },{ path: 'errors/[id]', url: '/errors/example-issue', component: IssueRoute, flag: FEATURE_FLAGS.errorTracking },- { path: 'replay/index', url: '/replay', component: ReplayRoute, flag: FEATURE_FLAGS.sessionReplay },+ { path: '(stack)/replay/index', url: '/replay', component: ReplayRoute, flag: FEATURE_FLAGS.sessionReplay },{path: 'replay/[sessionId]',url: '/replay/example-session',diff --git a/products/mobile/src/features/tabs/ReportNavigation.tsx b/products/mobile/src/features/tabs/ReportNavigation.tsxindex b5c4de5f7a26..693be7aa17d7 100644--- a/products/mobile/src/features/tabs/ReportNavigation.tsx+++ b/products/mobile/src/features/tabs/ReportNavigation.tsx@@ -3,6 +3,7 @@ import type { ReactElement } from 'react'import { useMobileProductFlags } from '@/lib/featureFlags'import { BottomBar } from './BottomBar'+import { openNavTarget } from './navPinRoutes'import { useNavPins } from './navPinStore'export function ReportNavigation(): ReactElement {@@ -16,7 +17,7 @@ export function ReportNavigation(): ReactElement {onHome={() => router.navigate('/inbox')}onChats={() => router.navigate('/chats')}onViews={() => router.navigate('/views')}- onPin={(pin) => router.navigate(pin === 'errors' ? '/errors' : '/replay')}+ onPin={(pin) => openNavTarget(router, pin, true)}/>)}diff --git a/products/mobile/src/features/tabs/navPinRoutes.test.tsx b/products/mobile/src/features/tabs/navPinRoutes.test.tsxindex aa4b9b204e33..83872ae73c6f 100644--- a/products/mobile/src/features/tabs/navPinRoutes.test.tsx+++ b/products/mobile/src/features/tabs/navPinRoutes.test.tsx@@ -1,30 +1,80 @@-import { router } from 'expo-router'+import { router, Stack } from 'expo-router'import { Tabs } from 'expo-router/js-tabs'+import { NativeTabs } from 'expo-router/native-tabs'import { act, renderRouter } from 'expo-router/testing-library'import type { ReactElement } from 'react'import { View } from 'react-native'import { openNavTarget } from './navPinRoutes'+import { type NavPin, restoreNavPins, useNavPins } from './navPinStore'jest.mock('react-native-worklets', () => jest.requireActual('react-native-worklets/src/mock'))function TabsStub(): ReactElement {- return <Tabs />+ return (+ <Tabs>+ <Tabs.Screen name="inbox" />+ <Tabs.Screen name="views" />+ <Tabs.Screen name="errors" />+ <Tabs.Screen name="replay" />+ </Tabs>+ )+}++function NativeTabsStub(): ReactElement {+ const pins = useNavPins()+ return (+ <NativeTabs>+ <NativeTabs.Trigger name="inbox" />+ <NativeTabs.Trigger name="views" />+ <NativeTabs.Trigger name="errors" hidden={!pins.includes('errors')} />+ <NativeTabs.Trigger name="replay" hidden={!pins.includes('replay')} />+ </NativeTabs>+ )+}++function ListStack(): ReactElement {+ return <Stack screenOptions={{ headerShown: false }} />}function Screen(): ReactElement {return <View />}-test('an unpinned list opens the pushed screen and a pinned one its tab, though both answer /errors', async () => {- const app = await renderRouter(- { '(tabs)/_layout': TabsStub, '(tabs)/inbox': Screen, '(tabs)/errors': Screen, 'errors/index': Screen },- { initialUrl: '/inbox' }- )+describe('pinnable list navigation', () => {+ afterEach(() => act(() => restoreNavPins([])))++ test.each([+ { layout: 'native', TabLayout: NativeTabsStub, pin: 'errors' as NavPin },+ { layout: 'native', TabLayout: NativeTabsStub, pin: 'replay' as NavPin },+ { layout: 'custom', TabLayout: TabsStub, pin: 'errors' as NavPin },+ { layout: 'custom', TabLayout: TabsStub, pin: 'replay' as NavPin },+ ])('$layout opens $pin above Views when unpinned and in its tab when pinned', async ({ TabLayout, pin }) => {+ const app = await renderRouter(+ {+ _layout: ListStack,+ '(tabs)/_layout': TabLayout,+ '(tabs)/inbox': Screen,+ '(tabs)/views': Screen,+ '(tabs)/errors/_layout': ListStack,+ '(tabs)/errors/index': Screen,+ '(tabs)/replay/_layout': ListStack,+ '(tabs)/replay/index': Screen,+ '(stack)/errors/index': Screen,+ '(stack)/replay/index': Screen,+ },+ { initialUrl: '/(tabs)/views' }+ )+ expect(app.getSegments()).toEqual(['(tabs)', 'views'])++ act(() => openNavTarget(router, pin, false))+ expect(app.getSegments()).toEqual(['(stack)', pin])- act(() => openNavTarget(router, 'errors', false))- expect(app.getSegments()).toEqual(['errors'])+ act(() => router.back())+ expect(app.getSegments()).toEqual(['(tabs)', 'views'])- act(() => openNavTarget(router, 'errors', true))- expect(app.getSegments()).toEqual(['(tabs)', 'errors'])+ act(() => restoreNavPins([pin]))+ act(() => openNavTarget(router, pin, true))+ expect(app.getSegments()).toEqual(['(tabs)', pin])+ })})diff --git a/products/mobile/src/features/tabs/navPinRoutes.ts b/products/mobile/src/features/tabs/navPinRoutes.tsindex ad808dcd330f..6190369741d4 100644--- a/products/mobile/src/features/tabs/navPinRoutes.ts+++ b/products/mobile/src/features/tabs/navPinRoutes.ts@@ -2,10 +2,9 @@ import type { Href, ImperativeRouter } from 'expo-router'import type { NavPin } from './navPinStore'-// `/errors` names both the tab and the stack screen. A path without the group opens the stack screen, so the tab is-// reached through its group.+// Both navigators share the public list URLs. Explicit groups keep a pushed list from resolving to a hidden tab.const TAB_HREFS: Record<NavPin, Href> = { errors: '/(tabs)/errors', replay: '/(tabs)/replay' }-const STACK_HREFS: Record<NavPin, Href> = { errors: '/errors', replay: '/replay' }+const STACK_HREFS: Record<NavPin, Href> = { errors: '/(stack)/errors', replay: '/(stack)/replay' }export function navTargetHref(pin: NavPin, pinned: boolean): Href {return pinned ? TAB_HREFS[pin] : STACK_HREFS[pin]diff --git a/products/mobile/src/lib/deepLinkKind.test.ts b/products/mobile/src/lib/deepLinkKind.test.tsindex db6ec442bfc1..5707cb7f8a0a 100644--- a/products/mobile/src/lib/deepLinkKind.test.ts+++ b/products/mobile/src/lib/deepLinkKind.test.ts@@ -22,6 +22,9 @@ describe('deepLinkKind', () => {})test.each<[string, string | null]>([+ ['https://us.posthog.com/project/2/error_tracking', '/(stack)/errors'],+ ['https://us.posthog.com/project/2/replay', '/(stack)/replay'],+ ['https://us.posthog.com/project/2/replay/home', '/(stack)/replay'],['https://us.posthog.com/project/2/error_tracking/0192-abc?fingerprint=x', '/errors/0192-abc?from=link'],['https://us.posthog.com/project/2/error-tracking/0192-abc', '/errors/0192-abc?from=link'],['https://us.posthog.com/project/2/error_tracking/configuration', null],diff --git a/products/mobile/src/lib/deepLinkKind.ts b/products/mobile/src/lib/deepLinkKind.tsindex 7a5611b2f832..129ec5b51c9b 100644--- a/products/mobile/src/lib/deepLinkKind.ts+++ b/products/mobile/src/lib/deepLinkKind.ts@@ -110,7 +110,7 @@ export function webLinkTarget(path: string): string | null {}if (section === 'error_tracking' || section === 'error-tracking') {if (id === undefined) {- return '/errors'+ return '/(stack)/errors'}return ERROR_TRACKING_PAGES.has(id) ? null : `/errors/${id}?from=link`}@@ -120,7 +120,7 @@ export function webLinkTarget(path: string): string | null {if (sessionId !== null && SAFE_ID.test(sessionId)) {return sessionPath(sessionId, query)}- return '/replay'+ return '/(stack)/replay'}return REPLAY_PAGES.has(id) ? null : sessionPath(id, query)}