Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: plan poller for issue/rollout refresh (#16968)

boojack3e99839803d6
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index d693342b43..f8485cfd37 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -33,7 +33,7 @@ import { useDialog } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { usePlanContext } from "@/components/Plan/logic";
-import { provideIssueReviewContext } from "@/components/Plan/logic/issue-review";
+import { useIssueReviewContext } from "@/components/Plan/logic/issue-review";
import { useResourcePoller } from "@/components/Plan/logic/poller";
import {
useCurrentUserV1,
@@ -67,13 +67,13 @@ import {
const { t } = useI18n();
const dialog = useDialog();
const resourcePoller = useResourcePoller();
-const { isCreating, plan, issue, rollout } = usePlanContext();
+const { isCreating, plan, issue } = usePlanContext();
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
const planStore = usePlanStore();
// Provide issue review context when an issue exists
-const reviewContext = provideIssueReviewContext(issue);
+const reviewContext = useIssueReviewContext();
// Panel visibility state
const pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);
@@ -88,17 +88,15 @@ const availableActions = computed(() => {
const currentUserEmail = currentUser.value.email;
// If no issue exists, show create issue action or close plan action.
- if (!issue?.value) {
+ if (plan.value.issue === "") {
// If rollout exists, no actions are available.
- if (rollout?.value) {
+ if (plan.value.rollout !== "") {
return actions;
}
// Check if user can close the plan
const canClosePlan =
plan.value.state === State.ACTIVE &&
- plan.value.issue === "" &&
- plan.value.rollout === "" &&
(currentUserEmail === extractUserId(plan.value.creator || "") ||
hasProjectPermissionV2(project.value, "bb.plans.update"));
@@ -109,8 +107,6 @@ const availableActions = computed(() => {
// Check if user can reopen the plan
const canReopenPlan =
plan.value.state === State.DELETED &&
- plan.value.issue === "" &&
- plan.value.rollout === "" &&
currentUserEmail === extractUserId(plan.value.creator || "") &&
hasProjectPermissionV2(project.value, "bb.plans.update");
@@ -129,7 +125,9 @@ const availableActions = computed(() => {
return actions;
}
- const issueValue = issue.value;
+ const issueValue = issue?.value;
+ // Should not reach here.
+ if (!issueValue) return actions;
const isCanceled = issueValue.status === IssueStatus.CANCELED;
const isDone = issueValue.status === IssueStatus.DONE;
diff --git a/frontend/src/components/Plan/components/RefreshIndicator.vue b/frontend/src/components/Plan/components/RefreshIndicator.vue
index 9ca86734a6..2c8e0ec335 100644
--- a/frontend/src/components/Plan/components/RefreshIndicator.vue
+++ b/frontend/src/components/Plan/components/RefreshIndicator.vue
@@ -70,6 +70,9 @@ const lastRefreshDisplay = computed(() => {
});
const handleRefresh = async () => {
- await resourcePoller.refreshResources();
+ await resourcePoller.refreshResources(
+ ["issue", "plan", "planCheckRuns", "rollout", "taskRuns"],
+ true /** force */
+ );
};
</script>
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 425b98f58a..c235fcbc4c 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -27,9 +27,9 @@ export type PlanContext = {
isCreating: Ref<boolean>;
plan: Ref<Plan>;
planCheckRuns: Ref<PlanCheckRun[]>;
- issue?: Ref<Issue | undefined>;
- rollout?: Ref<Rollout | undefined>;
- taskRuns?: Ref<TaskRun[]>;
+ issue: Ref<Issue | undefined>;
+ rollout: Ref<Rollout | undefined>;
+ taskRuns: Ref<TaskRun[]>;
readonly: ComputedRef<boolean>;
@@ -51,7 +51,7 @@ export const usePlanContext = () => {
export const usePlanContextWithIssue = () => {
const context = inject(KEY)!;
- if (!context.issue?.value) {
+ if (!context.issue.value) {
throw new Error("Issue is required but not available in plan context");
}
return {
@@ -62,7 +62,7 @@ export const usePlanContextWithIssue = () => {
export const usePlanContextWithRollout = () => {
const context = inject(KEY)!;
- if (!context.rollout?.value) {
+ if (!context.rollout.value) {
throw new Error("Rollout is required but not available in plan context");
}
return {
diff --git a/frontend/src/components/Plan/logic/issue-review.ts b/frontend/src/components/Plan/logic/issue-review.ts
index e37a8f651a..4fd83fa374 100644
--- a/frontend/src/components/Plan/logic/issue-review.ts
+++ b/frontend/src/components/Plan/logic/issue-review.ts
@@ -1,5 +1,5 @@
import { head } from "lodash-es";
-import type { InjectionKey, MaybeRef } from "vue";
+import type { ComputedRef, InjectionKey } from "vue";
import { computed, inject, provide, unref } from "vue";
import {
Issue_Approver_Status,
@@ -15,10 +15,10 @@ export const useIssueReviewContext = () => {
};
export const provideIssueReviewContext = (
- issue: MaybeRef<Issue | undefined>
+ issue: ComputedRef<Issue | undefined>
) => {
const status = computed(() => {
- const tempIssue = unref(issue);
+ const tempIssue = issue.value;
if (!tempIssue) {
return Issue_Approver_Status.PENDING;
}
diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.ts
index 5f1dc78fc4..3b1b1f4608 100644
--- a/frontend/src/components/Plan/logic/poller/poller.ts
+++ b/frontend/src/components/Plan/logic/poller/poller.ts
@@ -1,3 +1,4 @@
+import { create } from "@bufbuild/protobuf";
import { includes, uniq } from "lodash-es";
import { v4 as uuidv4 } from "uuid";
import {
@@ -21,6 +22,10 @@ import {
PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
} from "@/router/dashboard/projectV1";
import { useCurrentProjectV1 } from "@/store";
+import { isValidRolloutName } from "@/types";
+import { IssueSchema } from "@/types/proto-es/v1/issue_service_pb";
+import { RolloutSchema } from "@/types/proto-es/v1/rollout_service_pb";
+import { isValidIssueName } from "@/utils";
import { usePlanContext } from "../context";
import {
refreshPlan,
@@ -236,6 +241,50 @@ export const provideResourcePoller = () => {
{ deep: true }
);
+ // Watch for plan issue/rollout changes on plan pages
+ // This ensures we fetch issue/rollout once when they are created
+ watch(
+ () => ({
+ issue: plan.value?.issue,
+ rollout: plan.value?.rollout,
+ }),
+ async (newValues, oldValues) => {
+ const routeName = route.name as string;
+ // Only react to changes on plan-specific pages
+ if (
+ includes(
+ [
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ ],
+ routeName
+ )
+ ) {
+ // Check if issue or rollout was added (changed from empty to non-empty)
+ const issueAdded = !oldValues?.issue && newValues.issue;
+ const rolloutAdded = !oldValues?.rollout && newValues.rollout;
+
+ if (issueAdded && isValidIssueName(newValues.issue)) {
+ issue.value = create(IssueSchema, {
+ name: newValues.issue,
+ });
+ await refreshIssueOnly();
+ }
+ if (rolloutAdded && isValidRolloutName(newValues.rollout)) {
+ rollout.value = create(RolloutSchema, {
+ name: newValues.rollout,
+ });
+ await refreshRolloutOnly();
+ }
+ if (issueAdded || rolloutAdded) {
+ // Emit status changed to refresh the UI
+ events.emit("status-changed", { eager: true });
+ }
+ }
+ }
+ );
+
const refreshAll = async (isManual = false) => {
const activeResources = resourcesToPolled.value;
if (activeResources.length === 0 || isRefreshing.value) return;
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
index b8797ae0f8..506e47ec70 100644
--- a/frontend/src/views/project/CICDLayout.vue
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -147,7 +147,7 @@ providePlanContext({
...planBaseContext,
});
-provideIssueReviewContext(issue);
+provideIssueReviewContext(computed(() => issue.value));
watch(
() => isInitializing.value,