: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(cohorts): show cohort name in browser tab title (#66251)
Paul D'Ambrab78c9bc3fa31
diff --git a/frontend/src/models/cohortsModel.test.ts b/frontend/src/models/cohortsModel.test.tsindex ee481366f625..e511ecf1ea0c 100644--- a/frontend/src/models/cohortsModel.test.ts+++ b/frontend/src/models/cohortsModel.test.ts@@ -136,6 +136,36 @@ describe('cohortsModel', () => {})})+ it('adds a directly-opened cohort to cohortsById when not already loaded', async () => {+ // Mirrors cohortEditLogic.fetchCohort dispatching updateCohort for a cohort that+ // isn't in the loaded list (e.g. opened directly by URL) — its name must reach+ // cohortsById so the breadcrumb / browser tab title shows it instead of "Untitled".+ await expectLogic(logic).toDispatchActions(['loadAllCohortsSuccess'])++ const openedCohort: CohortType = {+ id: 99,+ name: 'Directly opened cohort',+ count: 0,+ groups: [],+ filters: {+ properties: {+ type: FilterLogicalOperator.And,+ values: [],+ },+ },+ is_calculating: false,+ is_static: false,+ }++ await expectLogic(logic, () => {+ logic.actions.updateCohort(openedCohort)+ }).toMatchValues({+ cohortsById: expect.objectContaining({+ 99: expect.objectContaining({ id: 99, name: 'Directly opened cohort' }),+ }),+ })+ })+it('can delete a cohort', async () => {// Wait for initial loadawait expectLogic(logic).toDispatchActions(['loadCohortsSuccess'])diff --git a/frontend/src/models/cohortsModel.ts b/frontend/src/models/cohortsModel.tsindex 5158ea627bef..a5814b730398 100644--- a/frontend/src/models/cohortsModel.ts+++ b/frontend/src/models/cohortsModel.ts@@ -212,11 +212,17 @@ export const cohortsModel = kea<cohortsModelType>([if (!cohort) {return state}+ // Upsert: a cohort opened directly (via cohortEditLogic.fetchCohort) may not be in+ // the list yet, so append it when missing — otherwise its name never reaches+ // cohortsById and the breadcrumb / browser tab title falls back to "Untitled".+ const exists = state.results.some((existingCohort) => existingCohort.id === cohort.id)return {...state,- results: state.results.map((existingCohort) =>- existingCohort.id === cohort.id ? cohort : existingCohort- ),+ results: exists+ ? state.results.map((existingCohort) =>+ existingCohort.id === cohort.id ? cohort : existingCohort+ )+ : [...state.results, cohort],}},cohortCreated: (state, { cohort }) => {