From c3e6439303a989e85edfd7745970db7bf20d87dc Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Fri, 14 Nov 2025 10:12:17 +0100 Subject: [PATCH] fix(editor): Refresh insights weekly summary when entering any of the /home routes (#21859) --- packages/frontend/editor-ui/src/app/init.ts | 6 ------ .../features/collaboration/projects/projects.routes.ts | 9 +++++++++ .../src/features/core/dataTable/module.descriptor.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/frontend/editor-ui/src/app/init.ts b/packages/frontend/editor-ui/src/app/init.ts index 0108e24f444..dc8514c8011 100644 --- a/packages/frontend/editor-ui/src/app/init.ts +++ b/packages/frontend/editor-ui/src/app/init.ts @@ -4,7 +4,6 @@ import { useExternalHooks } from '@/app/composables/useExternalHooks'; import { useTelemetry } from '@/app/composables/useTelemetry'; import { useToast } from '@/app/composables/useToast'; import { EnterpriseEditionFeature, VIEWS } from '@/app/constants'; -import { useInsightsStore } from '@/features/execution/insights/insights.store'; import type { UserManagementAuthenticationMethod } from '@/Interface'; import { registerModuleModals, @@ -134,7 +133,6 @@ export async function initializeAuthenticatedFeatures( const cloudPlanStore = useCloudPlanStore(); const projectsStore = useProjectsStore(); const rolesStore = useRolesStore(); - const insightsStore = useInsightsStore(); const bannersStore = useBannersStore(); const versionsStore = useVersionsStore(); const dataTableStore = useDataTableStore(); @@ -191,10 +189,6 @@ export async function initializeAuthenticatedFeatures( }); } - if (insightsStore.isSummaryEnabled) { - void insightsStore.weeklySummary.execute(); - } - // Don't check for new versions in preview mode or demo view (ex: executions iframe) if (!settingsStore.isPreviewMode && routeName !== VIEWS.DEMO) { void versionsStore.checkForNewVersions(); diff --git a/packages/frontend/editor-ui/src/features/collaboration/projects/projects.routes.ts b/packages/frontend/editor-ui/src/features/collaboration/projects/projects.routes.ts index 36ed3a6bbf2..004a5f06169 100644 --- a/packages/frontend/editor-ui/src/features/collaboration/projects/projects.routes.ts +++ b/packages/frontend/editor-ui/src/features/collaboration/projects/projects.routes.ts @@ -2,6 +2,7 @@ import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; import { VIEWS } from '@/app/constants'; import { useProjectsStore } from './projects.store'; import { getResourcePermissions } from '@n8n/permissions'; +import { useInsightsStore } from '@/features/execution/insights/insights.store'; const MainSidebar = async () => await import('@/app/components/MainSidebar.vue'); const WorkflowsView = async () => await import('@/app/views/WorkflowsView.vue'); @@ -178,6 +179,14 @@ export const projectsRoutes: RouteRecordRaw[] = [ middleware: ['authenticated'], }, redirect: '/home/workflows', + beforeEnter: (_to, _from, next) => { + const insightsStore = useInsightsStore(); + if (insightsStore.isSummaryEnabled) { + // refresh the weekly summary when entering the home route + void insightsStore.weeklySummary.execute(); + } + next(); + }, children: commonChildRoutes.map((route, idx) => ({ ...route, name: commonChildRouteExtensions.home[idx].name, diff --git a/packages/frontend/editor-ui/src/features/core/dataTable/module.descriptor.ts b/packages/frontend/editor-ui/src/features/core/dataTable/module.descriptor.ts index 2129a5380e9..e592c4d982c 100644 --- a/packages/frontend/editor-ui/src/features/core/dataTable/module.descriptor.ts +++ b/packages/frontend/editor-ui/src/features/core/dataTable/module.descriptor.ts @@ -6,6 +6,7 @@ import { DATA_TABLE_VIEW, PROJECT_DATA_TABLES, } from '@/features/core/dataTable/constants'; +import { useInsightsStore } from '@/features/execution/insights/insights.store'; const i18n = useI18n(); @@ -37,6 +38,14 @@ export const DataTableModule: FrontendModuleDescription = { meta: { middleware: ['authenticated', 'custom'], }, + beforeEnter: (_to, _from, next) => { + const insightsStore = useInsightsStore(); + if (insightsStore.isSummaryEnabled) { + // refresh the weekly summary when entering the datatables route + void insightsStore.weeklySummary.execute(); + } + next(); + }, }, { name: PROJECT_DATA_TABLES,