: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(dashboards): reload tiles when an insight rename lands before they are in state (#84106)
Paul D'Ambra9e18d4aa3050
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.tsindex e8925bf9ef4a..ed888c14e8e1 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts@@ -2522,6 +2522,30 @@ describe('dashboardLogic', () => {.toFinishAllListeners().toDispatchActions(['loadDashboard'])})++ it('reloads when an external rename lands before the tile is in state', async () => {+ await expectLogic(logic, () => {+ insightsModel.actions.renameInsightSuccess({+ ...insight800(),+ short_id: 'not_already_on_the_dashboard' as InsightShortId,+ dashboard_tiles: [{ id: 1, dashboard_id: 9 }],+ })+ })+ .toFinishAllListeners()+ .toDispatchActions(['loadDashboard'])+ })++ it('does not reload when an external rename targets a different dashboard only', async () => {+ const loadDashboardSpy = jest.spyOn(logic.actions, 'loadDashboard')+ await expectLogic(logic, () => {+ insightsModel.actions.renameInsightSuccess({+ ...insight800(),+ short_id: 'not_already_on_the_dashboard' as InsightShortId,+ dashboard_tiles: [{ id: 1, dashboard_id: 10 }],+ })+ }).toFinishAllListeners()+ expect(loadDashboardSpy).not.toHaveBeenCalled()+ })})describe('text tiles', () => {diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsxindex 5bbd6baef35e..19f1da994952 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx@@ -3387,6 +3387,21 @@ export const dashboardLogic = kea<dashboardLogicType>([actions.loadDashboard({ action: DashboardLoadAction.Update })}},+ [insightsModel.actionTypes.renameInsightSuccess]: ({ item }: { item: QueryBasedInsightModel }) => {+ const targetDashboards = (item.dashboard_tiles || []).map((tile) => tile.dashboard_id)+ if (!targetDashboards.includes(props.id)) {+ // this update is not for this dashboard+ return+ }++ const tileIndex = values.tiles.findIndex((t) => !!t.insight && t.insight.short_id === item.short_id)++ if (tileIndex === -1) {+ // the rename landed before this dashboard had the tile in state, so the reducer+ // could not patch it and the tile would show the stale name forever - reload instead+ actions.loadDashboard({ action: DashboardLoadAction.Update })+ }+ },duplicateTile: () => {cache.widgetTileIdsBeforeDuplicate = new Set(values.widgetTiles.map((tile) => tile.id))},