Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update resource poller (#16780)
boojackd184611d3ae2
diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjsindex 4475442f28..1867852b2d 100644--- a/frontend/eslint.config.mjs+++ b/frontend/eslint.config.mjs@@ -16,12 +16,7 @@ export default [...vueI18n.configs["flat/recommended"],eslintPluginPrettierRecommended,{- ignores: [- "**/dist/**",- "**/node_modules/**",- "**/proto/**",- "**/proto-es/**",- ],+ ignores: ["**/dist/**", "**/node_modules/**", "**/proto-es/**"],},{rules: {diff --git a/frontend/src/components/Plan/PollerProvider.vue b/frontend/src/components/Plan/PollerProvider.vuenew file mode 100644index 0000000000..962e7ad164--- /dev/null+++ b/frontend/src/components/Plan/PollerProvider.vue@@ -0,0 +1,9 @@+<template>+ <slot />+</template>++<script lang="ts" setup>+import { provideResourcePoller } from "./logic/poller";++provideResourcePoller();+</script>diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksDrawer.vue b/frontend/src/components/Plan/components/ChecksView/ChecksDrawer.vuenew file mode 100644index 0000000000..11ccd381ed--- /dev/null+++ b/frontend/src/components/Plan/components/ChecksView/ChecksDrawer.vue@@ -0,0 +1,22 @@+<template>+ <Drawer v-bind="$attrs">+ <DrawerContent+ :title="$t('plan.navigator.checks')"+ class="w-[40rem] max-w-[100vw] relative"+ >+ <div class="-mx-6">+ <ChecksView class="!py-0" :defaultStatus="status" />+ </div>+ </DrawerContent>+ </Drawer>+</template>++<script setup lang="ts">+import { Drawer, DrawerContent } from "@/components/v2";+import type { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";+import ChecksView from "./ChecksView.vue";++defineProps<{+ status: PlanCheckRun_Result_Status;+}>();+</script>diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue b/frontend/src/components/Plan/components/ChecksView/ChecksView.vueindex 948871cf65..67f8d44462 100644--- a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue+++ b/frontend/src/components/Plan/components/ChecksView/ChecksView.vue@@ -6,22 +6,22 @@<!-- Check result summary with icons --><div class="flex items-center gap-3"><div- v-if="statusCounts.success > 0"+ v-if="statusCounts.error > 0"class="flex items-center gap-1 px-2 py-1 cursor-pointer":class="[selectedStatus &&- selectedStatus === PlanCheckRun_Result_Status.SUCCESS &&+ selectedStatus === PlanCheckRun_Result_Status.ERROR &&'bg-gray-100 rounded-lg',- 'text-lg text-success',+ 'text-lg text-error',]"- @click="toggleSelectedStatus(PlanCheckRun_Result_Status.SUCCESS)"+ @click="toggleSelectedStatus(PlanCheckRun_Result_Status.ERROR)">- <CheckCircleIcon class="w-6 h-6" />+ <XCircleIcon class="w-6 h-6" /><span>- {{ $t("common.success") }}+ {{ $t("common.error") }}</span><span class="font-semibold">- {{ statusCounts.success }}+ {{ statusCounts.error }}</span></div><div@@ -44,22 +44,22 @@</span></div><div- v-if="statusCounts.error > 0"+ v-if="statusCounts.success > 0"class="flex items-center gap-1 px-2 py-1 cursor-pointer":class="[selectedStatus &&- selectedStatus === PlanCheckRun_Result_Status.ERROR &&+ selectedStatus === PlanCheckRun_Result_Status.SUCCESS &&'bg-gray-100 rounded-lg',- 'text-lg text-error',+ 'text-lg text-success',]"- @click="toggleSelectedStatus(PlanCheckRun_Result_Status.ERROR)"+ @click="toggleSelectedStatus(PlanCheckRun_Result_Status.SUCCESS)">- <XCircleIcon class="w-6 h-6" />+ <CheckCircleIcon class="w-6 h-6" /><span>- {{ $t("common.error") }}+ {{ $t("common.success") }}</span><span class="font-semibold">- {{ statusCounts.error }}+ {{ statusCounts.success }}</span></div></div>@@ -68,12 +68,8 @@<!-- Results List --><div class="flex-1 overflow-y-auto">- <div v-if="isLoading" class="flex items-center justify-center py-12">- <BBSpin />- </div>-<div- v-else-if="filteredResults.length === 0"+ v-if="filteredResults.length === 0"class="flex flex-col items-center justify-center py-12"><CheckCircleIcon class="w-12 h-12 text-control-light opacity-50 mb-4" />@@ -107,11 +103,7 @@</div><div class="flex items-center gap-2">- <NBadge- :type="getStatusBadgeType(getCheckRunStatus(checkRun))"- :value="getStatusLabel(getCheckRunStatus(checkRun))"- />- <span class="text-xs text-control-lighter">+ <span class="text-xs text-control">{{ formatTime(checkRun.createTime) }}</span></div>@@ -126,7 +118,7 @@><component:is="getStatusIcon(result.status)"- class="w-4 h-4 mt-0.5 flex-shrink-0"+ class="w-5 h-5 flex-shrink-0":class="getStatusColor(result.status)"/>@@ -169,10 +161,8 @@ import {ShieldIcon,SearchCodeIcon,} from "lucide-vue-next";-import { NBadge } from "naive-ui";import { computed, ref } from "vue";import { useI18n } from "vue-i18n";-import { BBSpin } from "@/bbkit";import {PlanCheckRun_Result_Status,PlanCheckRun_Type,@@ -182,11 +172,16 @@ import { humanizeTs } from "@/utils";import { usePlanContext } from "../../logic/context";import DatabaseDisplay from "../common/DatabaseDisplay.vue";+const props = defineProps<{+ defaultStatus?: PlanCheckRun_Result_Status;+}>();+const { t } = useI18n();const { planCheckRuns } = usePlanContext();-const isLoading = ref(false);-const selectedStatus = ref<PlanCheckRun_Result_Status | undefined>(undefined);+const selectedStatus = ref<PlanCheckRun_Result_Status | undefined>(+ props.defaultStatus+);const hasFilters = computed(() => {return selectedStatus.value !== undefined;@@ -268,25 +263,6 @@ const getFilteredResults = (checkRun: PlanCheckRun) => {});};-const getCheckRunStatus = (- checkRun: PlanCheckRun-): PlanCheckRun_Result_Status => {- let hasError = false;- let hasWarning = false;-- for (const result of checkRun.results) {- if (result.status === PlanCheckRun_Result_Status.ERROR) {- hasError = true;- } else if (result.status === PlanCheckRun_Result_Status.WARNING) {- hasWarning = true;- }- }-- if (hasError) return PlanCheckRun_Result_Status.ERROR;- if (hasWarning) return PlanCheckRun_Result_Status.WARNING;- return PlanCheckRun_Result_Status.SUCCESS;-};-const getCheckTypeIcon = (type: PlanCheckRun_Type) => {switch (type) {case PlanCheckRun_Type.DATABASE_STATEMENT_ADVISE:@@ -343,32 +319,6 @@ const getStatusColor = (status: PlanCheckRun_Result_Status) => {}};-const getStatusBadgeType = (status: PlanCheckRun_Result_Status) => {- switch (status) {- case PlanCheckRun_Result_Status.ERROR:- return "error";- case PlanCheckRun_Result_Status.WARNING:- return "warning";- case PlanCheckRun_Result_Status.SUCCESS:- return "success";- default:- return "default";- }-};--const getStatusLabel = (status: PlanCheckRun_Result_Status) => {- switch (status) {- case PlanCheckRun_Result_Status.ERROR:- return "Error";- case PlanCheckRun_Result_Status.WARNING:- return "Warning";- case PlanCheckRun_Result_Status.SUCCESS:- return "Success";- default:- return "Unknown";- }-};-const formatTime = (timestamp: any): string => {if (!timestamp) return "";return humanizeTs(diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vueindex fed04f9e7e..88fa00bd69 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue@@ -161,8 +161,6 @@ const availableActions = computed(() => {actions.push("CLOSE");}- // No separate rollout creation - handled when creating issue-return actions;});diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex 764bf0c6ec..9d42a541ac 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -11,7 +11,7 @@<buttonv-if="summary.error > 0"class="flex items-center gap-1 hover:opacity-80"- @click="openDrawer('ERROR')"+ @click="openDrawer(PlanCheckRun_Result_Status.ERROR)"><XCircleIcon class="w-5 h-5 text-error" /><span class="text-error">{{ summary.error }}</span>@@ -19,7 +19,7 @@<buttonv-if="summary.warning > 0"class="flex items-center gap-1 hover:opacity-80"- @click="openDrawer('WARNING')"+ @click="openDrawer(PlanCheckRun_Result_Status.WARNING)"><AlertCircleIcon class="w-5 h-5 text-warning" /><span class="text-warning">{{ summary.warning }}</span>@@ -27,7 +27,7 @@<buttonv-if="summary.success > 0"class="flex items-center gap-1 hover:opacity-80"- @click="openDrawer('SUCCESS')"+ @click="openDrawer(PlanCheckRun_Result_Status.SUCCESS)"><CheckCircleIcon class="w-5 h-5 text-success" /><span class="text-success">{{ summary.success }}</span>@@ -49,118 +49,21 @@</div></div>- <!-- Status Drawer -->- <Drawer v-model:show="drawerVisible">- <DrawerContent- :title="drawerTitle"- class="w-[40rem] max-w-[100vw] relative"- >- <div class="w-full h-full flex flex-col">- <!-- Drawer Header -->- <div class="flex items-center justify-between px-4 py-3 border-b">- <div class="flex items-center gap-2">- <component- :is="getStatusIcon(selectedStatus)"- class="w-5 h-5"- :class="getStatusColor(selectedStatus)"- />- <h3 class="text-lg font-medium">{{ drawerTitle }}</h3>- </div>- </div>-- <!-- Drawer Content -->- <div class="flex-1 overflow-y-auto px-4 py-3">- <div v-if="drawerCheckRuns.length > 0" class="space-y-4">- <!-- Group by Check Type -->- <div- v-for="[checkType, checkRuns] in drawerCheckRunsByType"- :key="checkType"- class="space-y-2"- >- <div class="flex items-center gap-2 mb-3">- <component- :is="getCheckTypeIcon(checkType)"- class="w-5 h-5"- />- <span class="font-medium">- {{ getCheckTypeLabel(checkType) }}- </span>- <span class="text-control-light"- >({{ checkRuns.length }})</span- >- </div>-- <div class="space-y-3 pl-6">- <div- v-for="checkRun in checkRuns"- :key="checkRun.name"- class="space-y-2"- >- <div class="text-sm font-medium text-control">- <DatabaseDisplay :database="checkRun.target" />- </div>- <div- v-for="(result, idx) in getResultsByStatus(- checkRun,- selectedStatus- )"- :key="idx"- class="px-3 py-1 border rounded-lg bg-gray-50"- >- <div- class="text-sm"- :class="getStatusColor(selectedStatus)"- >- {{ result.title }}- </div>- <div- v-if="result.content"- class="text-xs text-control-light mt-0.5"- >- {{ result.content }}- </div>- <div- v-if="- (result as any).sqlReviewReport &&- (result as any).sqlReviewReport?.line > 0- "- class="text-xs text-control-lighter mt-0.5"- >- Line {{ (result as any).sqlReviewReport?.line }}, Column- {{ (result as any).sqlReviewReport?.column }}- </div>- </div>- </div>- </div>- </div>- </div>- <div v-else class="text-center py-8 text-control-light">- No {{ selectedStatus.toLowerCase() }} results- </div>- </div>- </div>- </DrawerContent>- </Drawer>+ <ChecksDrawer v-model:show="drawerVisible" :status="selectedStatus" /></div></template><script setup lang="ts">import { create } from "@bufbuild/protobuf";+import { isNumber } from "lodash-es";import {CheckCircleIcon,AlertCircleIcon,XCircleIcon,PlayIcon,- FileCodeIcon,- DatabaseIcon,- ShieldIcon,- SearchCodeIcon,} from "lucide-vue-next";import { NButton } from "naive-ui";import { computed, ref } from "vue";-import { useI18n } from "vue-i18n";-import Drawer from "@/components/v2/Container/Drawer.vue";-import DrawerContent from "@/components/v2/Container/DrawerContent.vue";import { planServiceClientConnect } from "@/grpcweb";import {useCurrentUserV1,@@ -168,91 +71,54 @@ import {pushNotification,extractUserId,} from "@/store";-import {- PlanCheckRun_Type,- RunPlanChecksRequestSchema,-} from "@/types/proto-es/v1/plan_service_pb";import {PlanCheckRun_Result_Status,- type PlanCheckRun,+ RunPlanChecksRequestSchema,} from "@/types/proto-es/v1/plan_service_pb";import { hasProjectPermissionV2 } from "@/utils";-import { planCheckRunListForSpec, planSpecHasPlanChecks } from "../../logic";+import { planSpecHasPlanChecks } from "../../logic";import { usePlanContext } from "../../logic/context";+import { useResourcePoller } from "../../logic/poller";+import ChecksDrawer from "../ChecksView/ChecksDrawer.vue";import { usePlanSpecContext } from "../SpecDetailView/context";-import DatabaseDisplay from "../common/DatabaseDisplay.vue";-const { t } = useI18n();const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();-const { plan, planCheckRuns } = usePlanContext();+const { plan } = usePlanContext();const { selectedSpec } = usePlanSpecContext();+const { requestEnhancedPolling } = useResourcePoller();const isRunningChecks = ref(false);const drawerVisible = ref(false);-const selectedStatus = ref<"ERROR" | "WARNING" | "SUCCESS">("ERROR");+const selectedStatus = ref<PlanCheckRun_Result_Status>(+ PlanCheckRun_Result_Status.SUCCESS+);const show = computed(() => {return planSpecHasPlanChecks(selectedSpec.value);});-const checkRunsForSpec = computed(() => {- return planCheckRunListForSpec(planCheckRuns.value, selectedSpec.value);-});-const summary = computed(() => {const result = { success: 0, warning: 0, error: 0 };- for (const checkRun of checkRunsForSpec.value) {- const status = getCheckRunStatus(checkRun);- if (status === PlanCheckRun_Result_Status.ERROR) {- result.error++;- } else if (status === PlanCheckRun_Result_Status.WARNING) {- result.warning++;- } else if (status === PlanCheckRun_Result_Status.SUCCESS) {- result.success++;- }+ if (+ plan.value.planCheckRunStatusCount["ERROR"] &&+ isNumber(plan.value.planCheckRunStatusCount["ERROR"])+ ) {+ result.error = plan.value.planCheckRunStatusCount["ERROR"];}- return result;-});--const drawerTitle = computed(() => {- if (selectedStatus.value === "ERROR") return "Error Details";- if (selectedStatus.value === "WARNING") return "Warning Details";- return "Success Details";-});--const drawerCheckRuns = computed(() => {- const result: PlanCheckRun[] = [];-- for (const checkRun of checkRunsForSpec.value) {- const status = getCheckRunStatus(checkRun);- if (- (selectedStatus.value === "ERROR" &&- status === PlanCheckRun_Result_Status.ERROR) ||- (selectedStatus.value === "WARNING" &&- status === PlanCheckRun_Result_Status.WARNING) ||- (selectedStatus.value === "SUCCESS" &&- status === PlanCheckRun_Result_Status.SUCCESS)- ) {- result.push(checkRun);- }+ if (+ plan.value.planCheckRunStatusCount["WARNING"] &&+ isNumber(plan.value.planCheckRunStatusCount["WARNING"])+ ) {+ result.warning = plan.value.planCheckRunStatusCount["WARNING"];}-- return result;-});--const drawerCheckRunsByType = computed(() => {- const groups = new Map<string, PlanCheckRun[]>();-- for (const checkRun of drawerCheckRuns.value) {- const type = PlanCheckRun_Type[checkRun.type];- if (!groups.has(type)) {- groups.set(type, []);- }- groups.get(type)!.push(checkRun);+ if (+ plan.value.planCheckRunStatusCount["SUCCESS"] &&+ isNumber(plan.value.planCheckRunStatusCount["SUCCESS"])+ ) {+ result.success = plan.value.planCheckRunStatusCount["SUCCESS"];}-- return groups;+ return result;});const allowRunChecks = computed(() => {@@ -264,55 +130,6 @@ const allowRunChecks = computed(() => {return hasProjectPermissionV2(project.value, "bb.planCheckRuns.run");});-const getCheckRunStatus = (- checkRun: PlanCheckRun-): PlanCheckRun_Result_Status => {- let hasError = false;- let hasWarning = false;-- for (const result of checkRun.results) {- if (result.status === PlanCheckRun_Result_Status.ERROR) {- hasError = true;- } else if (result.status === PlanCheckRun_Result_Status.WARNING) {- hasWarning = true;- }- }-- if (hasError) return PlanCheckRun_Result_Status.ERROR;- if (hasWarning) return PlanCheckRun_Result_Status.WARNING;- return PlanCheckRun_Result_Status.SUCCESS;-};--const getCheckTypeIcon = (type: string) => {- switch (type) {- case "DATABASE_STATEMENT_ADVISE":- return SearchCodeIcon;- case "DATABASE_STATEMENT_SUMMARY_REPORT":- return FileCodeIcon;- case "DATABASE_CONNECT":- return DatabaseIcon;- case "DATABASE_GHOST_SYNC":- return ShieldIcon;- default:- return FileCodeIcon;- }-};--const getCheckTypeLabel = (type: string) => {- switch (type) {- case "DATABASE_STATEMENT_ADVISE":- return t("task.check-type.sql-review");- case "DATABASE_STATEMENT_SUMMARY_REPORT":- return t("task.check-type.summary-report");- case "DATABASE_CONNECT":- return t("task.check-type.connection");- case "DATABASE_GHOST_SYNC":- return t("task.check-type.ghost-sync");- default:- return type;- }-};-const runChecks = async () => {if (!plan.value.name || !selectedSpec.value) return;@@ -322,6 +139,10 @@ const runChecks = async () => {name: plan.value.name,});await planServiceClientConnect.runPlanChecks(request);++ // After running checks, we need to refresh the plan and plan check runs.+ requestEnhancedPolling(["plan", "planCheckRuns"], true /** once */);+pushNotification({module: "bytebase",style: "SUCCESS",@@ -339,30 +160,10 @@ const runChecks = async () => {}};-const openDrawer = (status: "ERROR" | "WARNING" | "SUCCESS") => {+const openDrawer = (status: PlanCheckRun_Result_Status) => {+ // Fetch the latest plan check runs for the selected status.+ requestEnhancedPolling(["planCheckRuns"], true /** once */);selectedStatus.value = status;drawerVisible.value = true;};--const getStatusIcon = (status: string) => {- if (status === "ERROR") return XCircleIcon;- if (status === "WARNING") return AlertCircleIcon;- return CheckCircleIcon;-};--const getStatusColor = (status: string) => {- if (status === "ERROR") return "text-error";- if (status === "WARNING") return "text-warning";- return "text-success";-};--const getResultsByStatus = (checkRun: PlanCheckRun, status: string) => {- return checkRun.results.filter(- (result) =>- result.status ===- PlanCheckRun_Result_Status[- status as keyof typeof PlanCheckRun_Result_Status- ]- );-};</script>diff --git a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vueindex b6c6bb3e03..9b28ccec58 100644--- a/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue+++ b/frontend/src/components/Plan/components/SQLCheckV1Section/SQLCheckV1Section.vue@@ -54,64 +54,48 @@<!-- Status Drawer --><Drawer v-model:show="drawerVisible"><DrawerContent- :title="drawerTitle"+ :title="$t('plan.navigator.checks')"class="w-[40rem] max-w-[100vw] relative"><div class="w-full h-full flex flex-col">- <!-- Drawer Header -->- <div class="flex items-center justify-between px-2 py-2 border-b">- <div class="flex items-center gap-2">- <component- :is="getStatusIcon(selectedStatus)"- class="w-5 h-5"- :class="getStatusColor(selectedStatus)"- />- <h3 class="text-lg font-medium">{{ drawerTitle }}</h3>- </div>- </div>-<!-- Drawer Content -->- <div class="flex-1 overflow-y-auto py-2">- <div v-if="drawerAdvices.length > 0" class="space-y-2">- <div- v-for="(advice, idx) in drawerAdvices"- :key="idx"- class="space-y-1 p-3 border rounded-lg bg-gray-50"- >- <div class="flex items-start justify-between">- <div class="text-sm font-medium text-main">- {{ getAdviceTitle(advice) }}- </div>- <component- :is="getStatusIcon(advice.status)"- class="w-4 h-4 flex-shrink-0"- :class="getStatusColor(advice.status)"- />+ <div v-if="drawerAdvices.length > 0" class="w-full space-y-2">+ <div+ v-for="(advice, idx) in drawerAdvices"+ :key="idx"+ class="space-y-1 p-3 border rounded-lg bg-gray-50"+ >+ <div class="flex items-start justify-between">+ <div class="text-sm font-medium text-main">+ {{ getAdviceTitle(advice) }}</div>+ <component+ :is="getStatusIcon(advice.status)"+ class="w-4 h-4 flex-shrink-0"+ :class="getStatusColor(advice.status)"+ />+ </div>- <!-- Target Database -->- <div>- <DatabaseDisplay :database="advice.target" />- </div>+ <!-- Target Database -->+ <DatabaseDisplay :database="advice.target" />- <!-- Advice Content -->- <div v-if="advice.content" class="text-xs text-control-light">- {{ advice.content }}- </div>+ <!-- Advice Content -->+ <div v-if="advice.content" class="text-xs text-control-light">+ {{ advice.content }}+ </div>- <!-- Location Info -->- <div- v-if="advice.startPosition && advice.startPosition.line > 0"- class="text-xs text-control-lighter"- >- Line {{ advice.startPosition.line }}, Column- {{ advice.startPosition.column }}- </div>+ <!-- Location Info -->+ <div+ v-if="advice.startPosition && advice.startPosition.line > 0"+ class="text-xs text-control-lighter"+ >+ Line {{ advice.startPosition.line }}, Column+ {{ advice.startPosition.column }}</div></div>- <div v-else class="text-center py-8 text-control-light">- No {{ selectedStatus.toLowerCase() }} results- </div>+ </div>+ <div v-else class="w-full text-center py-8 text-control-light">+ No check results</div></div></DrawerContent>@@ -216,12 +200,6 @@ const summary = computed(() => {return result;});-const drawerTitle = computed(() => {- if (selectedStatus.value === "ERROR") return "Error Details";- if (selectedStatus.value === "WARNING") return "Warning Details";- return "Success Details";-});-const drawerAdvices = computed(() => {return allAdvices.value.filter((advice) => {if (selectedStatus.value === "ERROR") {diff --git a/frontend/src/components/Plan/logic/poller/index.ts b/frontend/src/components/Plan/logic/poller/index.tsindex 3699c194c2..13878355ed 100644--- a/frontend/src/components/Plan/logic/poller/index.ts+++ b/frontend/src/components/Plan/logic/poller/index.ts@@ -1,2 +1,2 @@export { getLastRefreshTime } from "./utils";-export { type ResourceType, useResourcePoller } from "./poller";+export { provideResourcePoller, useResourcePoller } from "./poller";diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.tsindex e45a579f16..e00b3ba490 100644--- a/frontend/src/components/Plan/logic/poller/poller.ts+++ b/frontend/src/components/Plan/logic/poller/poller.ts@@ -1,5 +1,14 @@-import { includes } from "lodash-es";-import { computed, ref, watch, watchEffect } from "vue";+import { includes, uniq } from "lodash-es";+import { v4 as uuidv4 } from "uuid";+import {+ computed,+ inject,+ provide,+ ref,+ watch,+ watchEffect,+ type InjectionKey,+} from "vue";import { useRoute } from "vue-router";import { useProgressivePoll } from "@/composables/useProgressivePoll";import {@@ -28,10 +37,6 @@ export type ResourceType =| "issueComments"| "rollout";-export interface ResourcePollerOptions {- resources?: ResourceType[];-}-// Progressive polling configuration:// - min: 2s - Initial polling interval// - max: 60s - Maximum polling interval after progressive growth@@ -39,8 +44,11 @@ export interface ResourcePollerOptions {// - jitter: ±3s - Random variation to prevent thundering herdconst POLLER_INTERVAL = { min: 2000, max: 60000, growth: 1.5, jitter: 3000 };-export const useResourcePoller = (options: ResourcePollerOptions = {}) => {- const { resources } = options;+const KEY = Symbol(+ `bb.plan.poller.${uuidv4()}`+) as InjectionKey<ResourcePollerContext>;++export const provideResourcePoller = () => {const route = useRoute();const { project } = useCurrentProjectV1();const { isCreating, plan, planCheckRuns, issue, rollout, events } =@@ -49,14 +57,38 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {// Track refreshing stateconst isRefreshing = ref(false);- const resourcesToPolled = computed<ResourceType[]>(() => {- // If specific resources are provided, use them directly- if (resources && resources.length > 0) {- return resources;+ const enhancedPollingResources = ref<ResourceType[]>([]);++ const requestEnhancedPolling = (+ resources: ResourceType[],+ once?: boolean+ ) => {+ if (once) {+ for (const resource of resources) {+ if (resource === "plan") {+ refreshPlanOnly();+ } else if (resource === "planCheckRuns") {+ refreshPlanCheckRunsOnly();+ } else if (resource === "issue") {+ refreshIssueOnly();+ } else if (resource === "issueComments") {+ refreshIssueCommentsOnly();+ } else if (resource === "rollout") {+ refreshRolloutOnly();+ }+ }+ restartActivePollers();+ } else {+ enhancedPollingResources.value = resources;}+ };- const routeName = route.name as string;+ const resourcesFromRoute = computed<ResourceType[]>(() => {+ if (isCreating.value) {+ return [];+ }+ const routeName = route.name as string;// Plan-specific pagesif (includes(@@ -97,6 +129,13 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {return ["plan", "issue", "issueComments", "rollout"];});+ const resourcesToPolled = computed<ResourceType[]>(() => {+ return uniq([+ ...enhancedPollingResources.value,+ ...resourcesFromRoute.value,+ ]);+ });+// Create refresh functions for each resourceconst refreshPlanOnly = async () => {if (!plan.value) return;@@ -148,42 +187,43 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {};};- // Create pollers for each resource with more reasonable intervals+ // Create pollers for each resourceconst planPoller = useProgressivePoll(wrapWithRefreshingState(refreshPlanOnly, "plan"),- {- interval: POLLER_INTERVAL,- }+ { interval: POLLER_INTERVAL });const planCheckRunsPoller = useProgressivePoll(wrapWithRefreshingState(refreshPlanCheckRunsOnly, "planCheckRuns"),- {- interval: POLLER_INTERVAL,- }+ { interval: POLLER_INTERVAL });const issuePoller = useProgressivePoll(wrapWithRefreshingState(refreshIssueOnly, "issue"),- {- interval: POLLER_INTERVAL,- }+ { interval: POLLER_INTERVAL });const issueCommentsPoller = useProgressivePoll(wrapWithRefreshingState(refreshIssueCommentsOnly, "issueComments"),- {- interval: POLLER_INTERVAL,- }+ { interval: POLLER_INTERVAL });const rolloutPoller = useProgressivePoll(wrapWithRefreshingState(refreshRolloutOnly, "rollout"),- {- interval: POLLER_INTERVAL,- }+ { interval: POLLER_INTERVAL });+ // Track if we've done initial refresh to avoid duplicate calls+ let hasInitialRefresh = false;+ // Track which pollers are currently running to avoid unnecessary restarts+ const pollerStates = {+ plan: false,+ planCheckRuns: false,+ issue: false,+ issueComments: false,+ rollout: false,+ };+// Function to restart all active pollers (resets progressive intervals)const restartActivePollers = () => {const activeResources = resourcesToPolled.value;@@ -227,8 +267,6 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {rolloutPoller.start();pollerStates.rollout = true;}-- // Note: No immediate refresh here - let the watchEffect handle it to avoid duplicates};// Watch for route changes and restart pollers only when resources actually change@@ -253,23 +291,6 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {{ deep: true });- // Set up event listeners- events.on("status-changed", async ({ eager }) => {- if (eager) {- await refreshAll();- }- });-- events.on("perform-issue-review-action", async () => {- await Promise.all([refreshIssueOnly(), refreshIssueCommentsOnly()]);- events.emit("status-changed", { eager: true });- });-- events.on("perform-issue-status-action", async () => {- await refreshIssueOnly();- events.emit("status-changed", { eager: true });- });-const refreshAll = async (isManual = false) => {const activeResources = resourcesToPolled.value;const refreshPromises = [];@@ -300,20 +321,25 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {const refreshAllManual = async () => {if (isRefreshing.value) return;-await refreshAll(true);};- // Track if we've done initial refresh to avoid duplicate calls- let hasInitialRefresh = false;- // Track which pollers are currently running to avoid unnecessary restarts- const pollerStates = {- plan: false,- planCheckRuns: false,- issue: false,- issueComments: false,- rollout: false,- };+ // Set up event listeners+ events.on("status-changed", async ({ eager }) => {+ if (eager) {+ await refreshAll();+ }+ });++ events.on("perform-issue-review-action", async () => {+ await Promise.all([refreshIssueOnly(), refreshIssueCommentsOnly()]);+ events.emit("status-changed", { eager: true });+ });++ events.on("perform-issue-status-action", async () => {+ await refreshIssueOnly();+ events.emit("status-changed", { eager: true });+ });// Watch for resource changes and start/stop pollers accordinglywatchEffect(() => {@@ -395,11 +421,26 @@ export const useResourcePoller = (options: ResourcePollerOptions = {}) => {}});- return {- refreshAll,+ const poller = {refreshAllManual,+ requestEnhancedPolling,restartActivePollers,- isRefreshing,+ isRefreshing: computed(() => isRefreshing.value),activeResources: resourcesToPolled,};++ provide(KEY, poller);+ return poller;+};++type ResourcePollerContext = ReturnType<typeof provideResourcePoller>;++export const useResourcePoller = () => {+ const context = inject(KEY);+ if (!context) {+ throw new Error(+ "useResourcePoller must be called within a component that provides PollerContext"+ );+ }+ return context;};diff --git a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vueindex 4cd6744bce..4ee96cf7a4 100644--- a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue+++ b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue@@ -1,5 +1,5 @@<template>- <div class="textlabel">+ <div><divclass="flex flex-col md:flex-row md:items-center gap-y-2 justify-between">diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vueindex 801ce246df..7c2de29606 100644--- a/frontend/src/views/project/CICDLayout.vue+++ b/frontend/src/views/project/CICDLayout.vue@@ -1,35 +1,37 @@<template><div class="relative overflow-x-hidden h-full"><template v-if="ready">- <div class="h-full flex flex-col">- <HeaderSection />- <NTabs- type="line"- :value="tabKey"- tab-class="first:ml-4"- @update-value="handleTabChange"- >- <NTab- v-for="tab in availableTabs"- :key="tab"- :name="tab"- :tab="tabRender(tab)"- @click="handleTabChange(tab)"- />+ <PollerProvider>+ <div class="h-full flex flex-col">+ <HeaderSection />+ <NTabs+ type="line"+ :value="tabKey"+ tab-class="first:ml-4"+ @update-value="handleTabChange"+ >+ <NTab+ v-for="tab in availableTabs"+ :key="tab"+ :name="tab"+ :tab="tabRender(tab)"+ @click="handleTabChange(tab)"+ />- <!-- Suffix slot -->- <template #suffix>- <div class="pr-4 flex flex-row justify-end items-center gap-4">- <CurrentSpecSelector v-if="tabKey === TabKey.Specifications" />- <RefreshIndicator v-if="!isCreating" />- </div>- </template>- </NTabs>+ <!-- Suffix slot -->+ <template #suffix>+ <div class="pr-4 flex flex-row justify-end items-center gap-4">+ <CurrentSpecSelector v-if="tabKey === TabKey.Specifications" />+ <RefreshIndicator v-if="!isCreating" />+ </div>+ </template>+ </NTabs>- <div class="flex-1 flex">- <router-view />+ <div class="flex-1 flex">+ <router-view />+ </div></div>- </div>+ </PollerProvider></template><div v-else class="w-full h-full flex flex-col items-center justify-center"><NSpin />@@ -49,6 +51,7 @@ import {useBasePlanContext,useInitializePlan,} from "@/components/Plan";+import PollerProvider from "@/components/Plan/PollerProvider.vue";import { HeaderSection } from "@/components/Plan/components";import CurrentSpecSelector from "@/components/Plan/components/CurrentSpecSelector.vue";import RefreshIndicator from "@/components/Plan/components/RefreshIndicator.vue";