: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(navigation): stop stale switch toast and welcome-modal org name (#80244)
posthog[bot]fa089efb6a21
diff --git a/frontend/src/scenes/teamLogic.tsx b/frontend/src/scenes/teamLogic.tsxindex 5963933897a1..5773a0daf084 100644--- a/frontend/src/scenes/teamLogic.tsx+++ b/frontend/src/scenes/teamLogic.tsx@@ -665,6 +665,10 @@ export const teamLogic = kea<teamLogicType>([},icon: <IconSwapHoriz />,})+ // Clear the flag so a later remount of this logic does not re-announce the same switch.+ if (appContext) {+ appContext.switched_team = null+ }}if (currentTeam) {diff --git a/frontend/src/scenes/welcome/welcomeDialogLogic.test.ts b/frontend/src/scenes/welcome/welcomeDialogLogic.test.tsindex c7bcfbc2d153..4eaeb958e20f 100644--- a/frontend/src/scenes/welcome/welcomeDialogLogic.test.ts+++ b/frontend/src/scenes/welcome/welcomeDialogLogic.test.ts@@ -150,4 +150,22 @@ describe('welcomeDialogLogic', () => {logic.actions.trackCardClick('dashboards', '/project/1/dashboard/42')expect(logic.values.interactedCards.dashboards).toBe(true)})++ it('refetches and shows the new org name after an org switch', async () => {+ // Both orgs keep the dialog eligible, so `shouldShowDialog` never flips and the automatic+ // refetch does not fire — the org-change refetch has to carry it, otherwise the previous+ // org name stays on screen.+ const orgA = { ...INVITED_USER.organization!, id: 'org-a-id', name: 'Acme Inc' }+ const orgB = { ...INVITED_USER.organization!, id: 'org-b-id', name: 'Beta Corp' }+ userLogic.actions.loadUserSuccess({ ...INVITED_USER, organization: orgA })+ logic = welcomeDialogLogic()+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadWelcomeDataSuccess'])+ expect(logic.values.organizationName).toBe('Acme Inc')++ userLogic.actions.loadUserSuccess({ ...INVITED_USER, organization: orgB })+ // Title must follow the user's current org even before the refetch lands.+ expect(logic.values.organizationName).toBe('Beta Corp')+ await expectLogic(logic).toDispatchActions(['resetForOrgChange', 'loadWelcomeData'])+ })})diff --git a/frontend/src/scenes/welcome/welcomeDialogLogic.ts b/frontend/src/scenes/welcome/welcomeDialogLogic.tsindex ec3b015c38b6..ea1763f2a532 100644--- a/frontend/src/scenes/welcome/welcomeDialogLogic.ts+++ b/frontend/src/scenes/welcome/welcomeDialogLogic.ts@@ -340,8 +340,15 @@ export const welcomeDialogLogic = kea<welcomeDialogLogicType>([],organizationName: [(s) => [s.welcomeData, s.user],- (data: WelcomePayload, user: null | import('../../types').UserType): string =>- data.organization_name || user?.organization?.name || '',+ (data: WelcomePayload, user: null | import('../../types').UserType): string => {+ const userOrgName = user?.organization?.name+ // After an org switch the cached payload still names the previous org until the+ // refetch lands. Prefer the user's current org so the title never lags behind.+ if (userOrgName && data.organization_name && data.organization_name !== userOrgName) {+ return userOrgName+ }+ return data.organization_name || userOrgName || ''+ },],// Open for invitees (not the org creator) and for partner-provisioned accounts (which have no// inviter, so they'd otherwise never see it), when not already dismissed.@@ -370,6 +377,13 @@ export const welcomeDialogLogic = kea<welcomeDialogLogicType>([}),listeners(({ actions, values }) => ({+ resetForOrgChange: () => {+ // The cached payload belongs to the previous org. Refetch so the members, dashboards,+ // activity, and org name all reflect the org the user just switched to. The automatic+ // refetch only fires when `shouldShowDialog` flips, which it does not when the dialog+ // was eligible in both orgs.+ actions.loadWelcomeData()+ },loadWelcomeDataSuccess: ({ welcomeData }) => {if (!values.shouldShowDialog || values.welcomeDataError) {return