Skip to content

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

feat: add failed task runs section to spec detail view (#17143)

boojack13c7facaf689
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRunComment.vue b/frontend/src/components/Plan/components/RolloutView/TaskRunComment.vue
index 49338aad46..fc1684bf6a 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRunComment.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRunComment.vue
@@ -1,6 +1,10 @@
<template>
<div class="flex flex-col xl:flex-row xl:items-center xl:space-x-1">
- <NEllipsis expand-trigger="click" line-clamp="2" :tooltip="false">
+ <NEllipsis
+ :expand-trigger="expandTrigger || undefined"
+ :line-clamp="lineClamp"
+ :tooltip="false"
+ >
<span>{{ comment }}</span>
</NEllipsis>
<template v-if="commentLink.link">
@@ -40,9 +44,17 @@ export type CommentLink = {
link: string;
};
-const props = defineProps<{
- taskRun: TaskRun;
-}>();
+const props = withDefaults(
+ defineProps<{
+ taskRun: TaskRun;
+ expandTrigger?: false | "click";
+ lineClamp?: number;
+ }>(),
+ {
+ expandTrigger: "click",
+ lineClamp: 2,
+ }
+);
const { t } = useI18n();
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue b/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
index 0d980ed770..841037b5fc 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRunTable.vue
@@ -17,7 +17,7 @@
v-if="taskRunDetailContext.taskRun"
:key="taskRunDetailContext.taskRun.name"
:task-run="taskRunDetailContext.taskRun"
- :database="databaseForTask(project, task)"
+ :database="database"
/>
</DrawerContent>
</Drawer>
@@ -45,7 +45,7 @@ import { databaseForTask } from "@/utils";
import { humanizeDurationV1 } from "@/utils";
import TaskRunComment from "./TaskRunComment.vue";
-defineProps<{
+const props = defineProps<{
task: Task;
taskRuns: TaskRun[];
}>();
@@ -53,6 +53,10 @@ defineProps<{
const { t } = useI18n();
const { project } = useCurrentProjectV1();
+const database = computed(() => {
+ return databaseForTask(project.value, props.task);
+});
+
const taskRunDetailContext = ref<{
show: boolean;
taskRun?: TaskRun;
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskView.vue b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
index 3d7d75a2ce..66ac156327 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
@@ -9,30 +9,15 @@
<DatabaseDisplay :database="database.name" :size="'large'" />
</div>
<div class="flex flex-row gap-x-2">
+ <NTag round>
+ {{ semanticTaskType(task.type) }}
+ </NTag>
<NTooltip v-if="schemaVersion">
<template #trigger>
<NTag round>{{ schemaVersion }}</NTag>
</template>
{{ $t("common.version") }}
</NTooltip>
- <RouterLink
- v-if="relatedSpec"
- :to="{
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
- params: {
- projectId: extractProjectResourceName(plan.name),
- planId: extractPlanUID(plan.name),
- specId: relatedSpec.id,
- },
- }"
- >
- <NTag round class="cursor-pointer hover:opacity-80">
- <span class="text-control-light"
- >{{ $t("plan.spec.change") }}:</span
- >
- {{ getSpecTitle(relatedSpec) }}
- </NTag>
- </RouterLink>
<NTooltip v-if="task.runTime">
<template #trigger>
<NTag round>
@@ -100,7 +85,28 @@
<div class="w-full flex-1 min-h-0">
<div class="flex items-center justify-between mb-2">
<span class="text-base font-medium">{{ $t("common.statement") }}</span>
- <CopyButton v-if="statement" :size="'medium'" :content="statement" />
+ <div>
+ <RouterLink
+ v-if="relatedSpec"
+ :to="{
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(plan.name),
+ planId: extractPlanUID(plan.name),
+ specId: relatedSpec.id,
+ },
+ }"
+ >
+ <NButton size="small" text type="primary">
+ <template #icon>
+ <LinkIcon :size="14" />
+ </template>
+ <span class="underline">
+ {{ $t("plan.spec.change") }}: {{ getSpecTitle(relatedSpec) }}
+ </span>
+ </NButton>
+ </RouterLink>
+ </div>
</div>
<MonacoEditor
v-if="statement"
@@ -122,14 +128,14 @@
<script setup lang="ts">
import dayjs from "dayjs";
import { last } from "lodash-es";
-import { CalendarClockIcon } from "lucide-vue-next";
-import { NTag, NTooltip } from "naive-ui";
+import { CalendarClockIcon, LinkIcon } from "lucide-vue-next";
+import { NButton, NTag, NTooltip } from "naive-ui";
import { computed, watchEffect } from "vue";
import { RouterLink } from "vue-router";
+import { semanticTaskType } from "@/components/IssueV1";
import TaskRunDetail from "@/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue";
import { MonacoEditor } from "@/components/MonacoEditor";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
-import { CopyButton } from "@/components/v2";
import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
import {
taskRunNamePrefix,
diff --git a/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue
new file mode 100644
index 0000000000..af6bb8d73b
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/FailedTaskRunsSection.vue
@@ -0,0 +1,316 @@
+<template>
+ <div v-if="shouldShowSection" class="w-full space-y-2 pt-3 px-4">
+ <div class="text-sm text-control">
+ {{ $t("task-run.failed-runs") }}
+ </div>
+ <div v-if="isLoading" class="flex items-center justify-center py-4">
+ <div class="text-sm text-control-light">Loading task runs...</div>
+ </div>
+ <NDataTable
+ v-else-if="taskRunList.length > 0"
+ size="small"
+ :row-key="rowKey"
+ :columns="columnList"
+ :data="taskRunList"
+ :max-height="400"
+ :row-props="rowProps"
+ :pagination="
+ taskRunList.length > DEFAULT_TASK_RUNS_PER_PAGE
+ ? {
+ page: currentPage,
+ pageSize: DEFAULT_TASK_RUNS_PER_PAGE,
+ showSizePicker: false,
+ itemCount: taskRunList.length,
+ simple: false,
+ size: 'small',
+ onUpdatePage: (page: number) => {
+ currentPage = page;
+ },
+ }
+ : false
+ "
+ />
+ <div v-else class="text-sm text-control-light py-4">
+ No task runs found.
+ </div>
+ <Drawer v-model:show="taskRunDetailContext.show">
+ <DrawerContent
+ :title="$t('common.detail')"
+ style="width: calc(100vw - 14rem)"
+ >
+ <TaskRunDetail
+ v-if="taskRunDetailContext.taskRun && selectedDatabase"
+ :key="taskRunDetailContext.taskRun.name"
+ :task-run="taskRunDetailContext.taskRun"
+ :database="selectedDatabase"
+ />
+ </DrawerContent>
+ </Drawer>
+ </div>
+</template>
+
+<script lang="tsx" setup>
+import { create } from "@bufbuild/protobuf";
+import { ExternalLinkIcon } from "lucide-vue-next";
+import { NButton, type DataTableColumn, NDataTable } from "naive-ui";
+import { computed, reactive, ref, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
+import TaskRunDetail from "@/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue";
+import TaskRunStatusIcon from "@/components/IssueV1/components/TaskRunSection/TaskRunStatusIcon.vue";
+import HumanizeDate from "@/components/misc/HumanizeDate.vue";
+import { Drawer, DrawerContent } from "@/components/v2";
+import { rolloutServiceClientConnect } from "@/grpcweb";
+import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL } from "@/router/dashboard/projectV1";
+import { useCurrentProjectV1, useDatabaseV1Store } from "@/store";
+import { getDateForPbTimestampProtoEs, type ComposedTaskRun } from "@/types";
+import {
+ TaskRun_Status,
+ GetTaskRunLogRequestSchema,
+ Task_Status,
+} from "@/types/proto-es/v1/rollout_service_pb";
+import {
+ extractTaskUID,
+ flattenTaskV1List,
+ extractProjectResourceName,
+} from "@/utils";
+import { usePlanContextWithRollout } from "../../logic";
+import TaskRunComment from "../RolloutView/TaskRunComment.vue";
+import DatabaseDisplay from "../common/DatabaseDisplay.vue";
+import { useSelectedSpec } from "./context";
+
+const DEFAULT_TASK_RUNS_PER_PAGE = 5;
+
+const { t } = useI18n();
+const router = useRouter();
+const { project } = useCurrentProjectV1();
+const { rollout, taskRuns } = usePlanContextWithRollout();
+const selectedSpec = useSelectedSpec();
+const databaseStore = useDatabaseV1Store();
+
+// Pagination state
+const currentPage = ref(1);
+
+const taskRunDetailContext = reactive<{
+ show: boolean;
+ taskRun?: ComposedTaskRun;
+}>({
+ show: false,
+});
+
+const failedSpecTasks = computed(() => {
+ const tasks = flattenTaskV1List(rollout.value);
+ return tasks.filter(
+ (task) =>
+ task.specId === selectedSpec.value.id &&
+ task.status === Task_Status.FAILED
+ );
+});
+
+const taskRunList = computed(() => {
+ if (failedSpecTasks.value.length === 0) {
+ return [];
+ }
+
+ const latestFailedTaskRuns: ComposedTaskRun[] = [];
+
+ // For each failed task, find its latest task run
+ for (const failedTask of failedSpecTasks.value) {
+ const taskUID = extractTaskUID(failedTask.name);
+
+ // Get all task runs for this failed task
+ const taskRunsForTask = taskRuns.value.filter(
+ (taskRun) => extractTaskUID(taskRun.name) === taskUID
+ ) as ComposedTaskRun[];
+
+ if (taskRunsForTask.length > 0) {
+ // Sort by creation time to get the latest first
+ const sortedTaskRuns = taskRunsForTask.sort((a, b) => {
+ const aTime = a.createTime ? Number(a.createTime.seconds) : 0;
+ const bTime = b.createTime ? Number(b.createTime.seconds) : 0;
+ return bTime - aTime; // Latest first
+ });
+
+ // Get the latest task run (first after sorting)
+ const latestTaskRun = sortedTaskRuns[0];
+ latestFailedTaskRuns.push(latestTaskRun);
+ }
+ }
+
+ return latestFailedTaskRuns;
+});
+
+// Determine if the section should be shown at all
+const shouldShowSection = computed(() => {
+ return failedSpecTasks.value.length > 0 || taskRuns.value.length > 0;
+});
+
+// Helper function to get the task for a task run
+const getTaskForTaskRun = (taskRun: ComposedTaskRun) => {
+ const taskUID = extractTaskUID(taskRun.name);
+ return failedSpecTasks.value.find(
+ (task) => extractTaskUID(task.name) === taskUID
+ );
+};
+
+// Determine if we're in a loading state
+const isLoading = computed(() => {
+ // We're loading if we have failed tasks, rollout exists, but no task runs loaded yet
+ const hasFailedTasks = failedSpecTasks.value.length > 0;
+ return (
+ hasFailedTasks && rollout.value !== undefined && taskRuns.value.length === 0
+ );
+});
+
+watchEffect(async () => {
+ for (const taskRun of taskRunList.value) {
+ if (taskRun.status === TaskRun_Status.RUNNING) {
+ const request = create(GetTaskRunLogRequestSchema, {
+ parent: taskRun.name,
+ });
+ const response = await rolloutServiceClientConnect.getTaskRunLog(request);
+ taskRun.taskRunLog = response;
+ }
+ }
+});
+
+const rowKey = (taskRun: ComposedTaskRun) => {
+ return taskRun.name;
+};
+
+const rowProps = (taskRun: ComposedTaskRun) => {
+ return {
+ style: "cursor: pointer;",
+ onClick: () => {
+ if (shouldShowDetailButton(taskRun)) {
+ showDetail(taskRun);
+ }
+ },
+ };
+};
+
+const columnList = computed((): DataTableColumn<ComposedTaskRun>[] => {
+ return [
+ {
+ key: "status",
+ title: "",
+ width: "30px",
+ render: (taskRun: ComposedTaskRun) => (
+ <TaskRunStatusIcon status={taskRun.status} />
+ ),
+ },
+ {
+ key: "database",
+ title: t("common.database"),
+ width: "256px",
+ resizable: true,
+ render: (taskRun: ComposedTaskRun) => {
+ const task = getTaskForTaskRun(taskRun);
+ return task?.target ? (
+ <DatabaseDisplay showEnvironment database={task.target} />
+ ) : (
+ "-"
+ );
+ },
+ },
+ {
+ key: "comment",
+ title: t("task.comment"),
+ resizable: true,
+ render: (taskRun: ComposedTaskRun) => (
+ <div class="flex flex-row justify-start items-center">
+ <TaskRunComment
+ taskRun={taskRun}
+ expandTrigger={false}
+ lineClamp={1}
+ />
+ </div>
+ ),
+ },
+ {
+ key: "startTime",
+ title: t("task.started"),
+ width: "100px",
+ render: (taskRun: ComposedTaskRun) => (
+ <HumanizeDate date={getDateForPbTimestampProtoEs(taskRun.startTime)} />
+ ),
+ },
+ {
+ key: "actions",
+ title: "",
+ width: "100px",
+ render: (taskRun: ComposedTaskRun) =>
+ shouldShowDetailButton(taskRun) ? (
+ <NButton
+ size="tiny"
+ onClick={() => navigateToTaskDetail(taskRun)}
+ iconPlacement="right"
+ >
+ {{
+ default: () => t("common.detail"),
+ icon: () => <ExternalLinkIcon class="w-3 h-3" />,
+ }}
+ </NButton>
+ ) : null,
+ },
+ ];
+});
+
+const shouldShowDetailButton = (taskRun: ComposedTaskRun) => {
+ return [
+ TaskRun_Status.RUNNING,
+ TaskRun_Status.DONE,
+ TaskRun_Status.FAILED,
+ TaskRun_Status.CANCELED,
+ ].includes(taskRun.status);
+};
+
+// Helper function to get route params for a task run
+const getTaskRouteParams = (taskRun: ComposedTaskRun) => {
+ const task = getTaskForTaskRun(taskRun);
+ if (!task) return null;
+
+ // Extract IDs from task name (format: projects/xxx/rollouts/yyy/stages/zzz/tasks/aaa)
+ const taskParts = task.name.split("/");
+ const rolloutId = rollout.value.name.split("/").pop();
+ const stageIndex = taskParts.indexOf("stages");
+ const taskIndex = taskParts.indexOf("tasks");
+
+ if (stageIndex === -1 || taskIndex === -1) return null;
+
+ const stageId = taskParts[stageIndex + 1];
+ const taskId = taskParts[taskIndex + 1];
+
+ return { rolloutId, stageId, taskId };
+};
+
+// Get database for selected task run
+const selectedDatabase = computed(() => {
+ if (!taskRunDetailContext.taskRun) return undefined;
+ const task = getTaskForTaskRun(taskRunDetailContext.taskRun);
+ if (!task?.target) return undefined;
+ return databaseStore.getDatabaseByName(task.target);
+});
+
+// Navigate to task detail page
+const navigateToTaskDetail = (taskRun: ComposedTaskRun) => {
+ const params = getTaskRouteParams(taskRun);
+ if (params) {
+ router.push({
+ name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(project.value.name),
+ rolloutId: params.rolloutId,
+ stageId: params.stageId,
+ taskId: params.taskId,
+ },
+ });
+ }
+};
+
+// Show task run detail in drawer
+const showDetail = (taskRun: ComposedTaskRun) => {
+ taskRunDetailContext.taskRun = taskRun;
+ taskRunDetailContext.show = true;
+};
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
index 74784e2a10..f8b3dac70a 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
@@ -5,6 +5,7 @@
<div class="w-full flex flex-col">
<SpecListSection v-if="isCreating || plan.specs.length > 1" />
<TargetListSection />
+ <FailedTaskRunsSection v-if="!isCreating && rollout" />
</div>
<template v-if="!specHasRelease">
<SQLCheckV1Section v-if="isCreating" />
@@ -28,12 +29,13 @@ import PlanCheckSection from "../PlanCheckSection";
import { providePlanSQLCheckContext } from "../SQLCheckSection";
import SQLCheckV1Section from "../SQLCheckV1Section";
import StatementSection from "../StatementSection";
+import FailedTaskRunsSection from "./FailedTaskRunsSection.vue";
import SpecListSection from "./SpecListSection.vue";
import TargetListSection from "./TargetListSection.vue";
import { useSelectedSpec } from "./context";
const { project } = useCurrentProjectV1();
-const { isCreating, plan } = usePlanContext();
+const { isCreating, plan, rollout } = usePlanContext();
const selectedSpec = useSelectedSpec();
diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.ts
index 7b17c9d0da..be0336385e 100644
--- a/frontend/src/components/Plan/logic/poller/poller.ts
+++ b/frontend/src/components/Plan/logic/poller/poller.ts
@@ -37,342 +37,303 @@ import {
type ResourceType = "plan" | "planCheckRuns" | "issue" | "rollout" | "taskRuns";
-// Progressive polling configuration for the resource poller
-// This configuration implements an exponential backoff strategy to reduce server load
-// while maintaining responsiveness for active users
-//
-// - min: 2000ms (2s) - Initial polling interval when starting or after user interaction
-// - max: 30000ms (30s) - Maximum polling interval to prevent excessive delays
-// - growth: 2 - Growth factor for exponential backoff (2x means: 2s → 4s → 8s → 16s → 30s)
-// - jitter: ±3000ms (±3s) - Random variation added to prevent thundering herd problem
-// where multiple clients poll simultaneously
-//
-// Example progression with growth=2:
-// Poll 1: 2s (initial)
-// Poll 2: 4s (2s × 2)
-// Poll 3: 8s (4s × 2)
-// Poll 4: 16s (8s × 2)
-// Poll 5+: 30s (capped at max, would be 32s but limited by max)
-//
-// The actual interval will vary by ±3s due to jitter, so Poll 3 might be anywhere
-// from 5s to 11s (8s ± 3s), helping distribute server load
+// Progressive polling configuration.
const POLLER_INTERVAL = { min: 2000, max: 30000, growth: 2, jitter: 3000 };
const KEY = Symbol(
`bb.plan.poller.${uuidv4()}`
) as InjectionKey<ResourcePollerContext>;
+// Resource refresh strategies
+interface ResourceRefreshStrategy {
+ canRefresh: () => boolean;
+ refresh: () => Promise<void>;
+ canInitialize?: () => boolean;
+ initialize?: () => Promise<void>;
+}
+
export const provideResourcePoller = () => {
const route = useRoute();
const { project } = useCurrentProjectV1();
const { isCreating, plan, planCheckRuns, taskRuns, issue, rollout, events } =
usePlanContext();
- // Track refreshing state
- const isRefreshing = ref(false);
+ // Consolidated state management
+ const pollerState = ref({
+ isRefreshing: false,
+ lastRefreshTime: 0,
+ hasInitialRefresh: false,
+ hasInitialResourceSetup: false,
+ isPollerRunning: false,
+ });
- // Track last refresh time
- const lastRefreshTime = ref(0);
+ // Define refresh strategies for each resource
+ const resourceStrategies: Record<ResourceType, ResourceRefreshStrategy> = {
+ plan: {
+ canRefresh: () => !!plan.value,
+ refresh: () => refreshPlan(plan),
+ },
+ planCheckRuns: {
+ canRefresh: () => !!plan.value && !!planCheckRuns,
+ refresh: () =>
+ refreshPlanCheckRuns(plan.value, project.value, planCheckRuns),
+ },
+ issue: {
+ canRefresh: () => !!issue?.value,
+ refresh: () => refreshIssue(issue as any),
+ canInitialize: () =>
+ !!(plan.value?.issue && isValidIssueName(plan.value.issue)),
+ initialize: async () => {
+ if (!plan.value?.issue) return;
+ issue.value = create(IssueSchema, { name: plan.value.issue });
+ await resourceStrategies.issue.refresh();
+ },
+ },
+ rollout: {
+ canRefresh: () => !!plan.value?.rollout && !!rollout,
+ refresh: () => refreshRollout(plan.value.rollout, project.value, rollout),
+ canInitialize: () =>
+ !!plan.value?.rollout && isValidRolloutName(plan.value.rollout),
+ initialize: async () => {
+ if (!plan.value?.rollout) return;
+ rollout.value = create(RolloutSchema, { name: plan.value.rollout });
+ await resourceStrategies.rollout.refresh();
+ },
+ },
+ taskRuns: {
+ canRefresh: () => !!rollout?.value && !!taskRuns,
+ refresh: () => refreshTaskRuns(rollout.value!, project.value, taskRuns),
+ },
+ };
const resourcesFromRoute = computed<ResourceType[]>(() => {
- if (isCreating.value) {
- return [];
- }
+ if (isCreating.value) return [];
const routeName = route.name as string;
- // Plan-specific pages
- if (
- includes(
- [
- PROJECT_V1_ROUTE_PLAN_DETAIL,
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
- ],
- routeName
- )
- ) {
- return ["plan"];
- }
-
- // Issue-specific pages
- if (includes([PROJECT_V1_ROUTE_ISSUE_DETAIL_V1], routeName)) {
+ const planRoutes = [
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ ];
+ const rolloutRoutes = [
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
+ PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
+ ];
+
+ if (includes(planRoutes, routeName)) return ["plan"];
+ if (includes([PROJECT_V1_ROUTE_ISSUE_DETAIL_V1], routeName))
return ["issue"];
- }
+ if (includes(rolloutRoutes, routeName)) return ["rollout", "taskRuns"];
- // Rollout-specific pages
- if (
- includes(
- [
- PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
- PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,
- PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,
- ],
- routeName
- )
- ) {
- return ["rollout", "taskRuns"];
- }
-
- // Default to polling all resources
return ["plan", "planCheckRuns", "issue", "rollout", "taskRuns"];
});
- const resourcesToPolled = computed<ResourceType[]>(() => {
- return uniq([...resourcesFromRoute.value]);
- });
+ const resourcesToPolled = computed(() => uniq([...resourcesFromRoute.value]));
- // Create refresh functions for each resource
- const refreshPlanOnly = async () => {
- if (!plan.value) return;
- await refreshPlan(plan);
- };
+ // Initialize existing resources that are already on the plan
+ const initializeExistingResources = async () => {
+ if (
+ pollerState.value.hasInitialResourceSetup ||
+ isCreating.value ||
+ !plan.value
+ ) {
+ return;
+ }
- const refreshPlanCheckRunsOnly = async () => {
- if (!plan.value || !planCheckRuns) return;
- await refreshPlanCheckRuns(plan.value, project.value, planCheckRuns);
- };
+ pollerState.value.hasInitialResourceSetup = true;
+ const initPromises: Promise<void>[] = [];
- const refreshIssueOnly = async () => {
- if (!issue?.value) return;
- await refreshIssue(issue as any);
- };
+ // Initialize issue if needed
+ if (
+ resourceStrategies.issue.canInitialize?.() &&
+ resourceStrategies.issue.initialize
+ ) {
+ initPromises.push(resourceStrategies.issue.initialize());
+ }
- const refreshRolloutOnly = async () => {
- if (!plan.value?.rollout || !rollout) return;
- await refreshRollout(plan.value.rollout, project.value, rollout);
- };
+ // Initialize rollout and taskRuns with proper sequencing
+ if (
+ resourceStrategies.rollout.canInitialize?.() &&
+ resourceStrategies.rollout.initialize
+ ) {
+ initPromises.push(
+ resourceStrategies.rollout.initialize().then(async () => {
+ if (resourceStrategies.taskRuns.canRefresh()) {
+ await resourceStrategies.taskRuns.refresh();
+ }
+ })
+ );
+ }
- const refreshTaskRunsOnly = async () => {
- if (!rollout?.value || !taskRuns) return;
- await refreshTaskRuns(rollout.value, project.value, taskRuns);
+ if (initPromises.length > 0) {
+ await Promise.all(initPromises);
+ events.emit("status-changed", { eager: true });
+ }
};
+ // Unified refresh function (with backward compatibility)
const refreshResources = async (
resources: ResourceType[] = resourcesToPolled.value,
- force?: boolean
+ optionsOrForce: { force?: boolean; isManual?: boolean } | boolean = {}
) => {
- if ((resources.length === 0 || isRefreshing.value) && !force) return;
+ // Handle backward compatibility for boolean force parameter
+ const options =
+ typeof optionsOrForce === "boolean"
+ ? { force: optionsOrForce, isManual: true }
+ : optionsOrForce;
+ const { force = false, isManual = false } = options;
+
+ if ((resources.length === 0 || pollerState.value.isRefreshing) && !force) {
+ return;
+ }
- isRefreshing.value = true;
- const refreshPromises = [];
+ pollerState.value.isRefreshing = true;
+ const refreshPromises: Promise<void>[] = [];
try {
- if (resources.includes("plan") && plan.value) {
- refreshPromises.push(refreshPlan(plan));
- }
- if (resources.includes("planCheckRuns") && plan.value && planCheckRuns) {
- refreshPromises.push(
- refreshPlanCheckRuns(plan.value, project.value, planCheckRuns)
- );
- }
- if (resources.includes("issue") && issue?.value) {
- refreshPromises.push(refreshIssue(issue as any));
- }
- if (resources.includes("rollout") && plan.value?.rollout && rollout) {
- refreshPromises.push(
- refreshRollout(plan.value.rollout, project.value, rollout)
- );
- }
- if (resources.includes("taskRuns") && rollout?.value && taskRuns) {
- refreshPromises.push(
- refreshTaskRuns(rollout.value, project.value, taskRuns)
- );
+ for (const resourceType of resources) {
+ const strategy = resourceStrategies[resourceType];
+ if (strategy.canRefresh()) {
+ refreshPromises.push(strategy.refresh());
+ }
}
await Promise.all(refreshPromises);
- // Update timestamp after successful refresh
- lastRefreshTime.value = Date.now();
-
- // Emit event after successful refresh
- events.emit("resource-refresh-completed", {
- resources: resources,
- isManual: false,
- });
+ pollerState.value.lastRefreshTime = Date.now();
+ events.emit("resource-refresh-completed", { resources, isManual });
} finally {
- isRefreshing.value = false;
+ pollerState.value.isRefreshing = false;
}
- // If force is true, restart the poller to ensure it continues polling.
if (force) {
resourcePoller.restart();
}
};
- // Create a single poller for all resources
+ // Create the poller
const resourcePoller = useProgressivePoll(refreshResources, {
interval: POLLER_INTERVAL,
});
- // Track if we've done initial refresh to avoid duplicate calls
- let hasInitialRefresh = false;
- let isPollerRunning = false;
+ // Reset poller state
+ const resetPollerState = () => {
+ pollerState.value.hasInitialRefresh = false;
+ pollerState.value.hasInitialResourceSetup = false;
+ pollerState.value.isPollerRunning = false;
+ };
- // Function to restart the poller (resets progressive intervals)
+ // Restart poller with clean state
const restartPoller = () => {
const shouldPoll = !isCreating.value && resourcesToPolled.value.length > 0;
-
if (!shouldPoll) return;
- // Stop the poller first
resourcePoller.stop();
- isPollerRunning = false;
- hasInitialRefresh = false;
-
- // Restart the poller
+ resetPollerState();
resourcePoller.start();
- isPollerRunning = true;
+ pollerState.value.isPollerRunning = true;
};
- // Watch for route changes and restart poller only when resources actually change
+ // Watch for route changes and restart poller when resources change
watch(
- () => resourcesToPolled.value,
+ resourcesToPolled,
(newResources, oldResources) => {
- // Only restart if the resources to be polled have actually changed
- if (oldResources && newResources.length > 0) {
- // Create sorted arrays to compare
- const newSorted = [...newResources].sort();
- const oldSorted = [...oldResources].sort();
-
- const resourcesChanged =
- newSorted.length !== oldSorted.length ||
- newSorted.some((resource, index) => resource !== oldSorted[index]);
-
- if (resourcesChanged) {
- restartPoller();
- }
+ if (!oldResources || newResources.length === 0) return;
+
+ const newSorted = [...newResources].sort();
+ const oldSorted = [...oldResources].sort();
+ const resourcesChanged =
+ newSorted.length !== oldSorted.length ||
+ newSorted.some((resource, index) => resource !== oldSorted[index]);
+
+ if (resourcesChanged) {
+ restartPoller();
}
},
{ 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,
- }),
+ () => ({ 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;
-
- isRefreshing.value = true;
- const refreshPromises = [];
-
- try {
- if (activeResources.includes("plan"))
- refreshPromises.push(refreshPlanOnly());
- if (activeResources.includes("planCheckRuns"))
- refreshPromises.push(refreshPlanCheckRunsOnly());
- if (activeResources.includes("issue"))
- refreshPromises.push(refreshIssueOnly());
- if (activeResources.includes("rollout"))
- refreshPromises.push(refreshRolloutOnly());
- if (activeResources.includes("taskRuns"))
- refreshPromises.push(refreshTaskRunsOnly());
+ const isPlanRoute = includes(
+ [
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ ],
+ routeName
+ );
- await Promise.all(refreshPromises);
+ if (!isPlanRoute) return;
- // Update timestamp after successful refresh
- lastRefreshTime.value = Date.now();
+ const issueAdded = !oldValues?.issue && newValues.issue;
+ const rolloutAdded = !oldValues?.rollout && newValues.rollout;
- // Emit event after successful refresh
- events.emit("resource-refresh-completed", {
- resources: activeResources,
- isManual,
- });
- } finally {
- isRefreshing.value = false;
+ if (issueAdded && resourceStrategies.issue.initialize) {
+ await resourceStrategies.issue.initialize();
+ }
+ if (rolloutAdded && resourceStrategies.rollout.initialize) {
+ await resourceStrategies.rollout.initialize();
+ }
+ if (issueAdded || rolloutAdded) {
+ events.emit("status-changed", { eager: true });
+ }
}
- };
+ );
- // Set up event listeners
+ // Event listeners
events.on("status-changed", async ({ eager }) => {
if (eager) {
- await refreshAll();
+ await refreshResources(resourcesToPolled.value, { isManual: false });
}
});
events.on("perform-issue-review-action", async () => {
- await Promise.all([refreshIssueOnly()]);
+ await refreshResources(["issue"], { isManual: true });
events.emit("status-changed", { eager: true });
});
events.on("perform-issue-status-action", async () => {
- await refreshIssueOnly();
+ await refreshResources(["issue"], { isManual: true });
events.emit("status-changed", { eager: true });
});
- // Watch for resource changes and start/stop poller accordingly
- watchEffect(() => {
+ // Main poller lifecycle management
+ watchEffect(async () => {
const activeResources = resourcesToPolled.value;
const shouldPoll = !isCreating.value && activeResources.length > 0;
if (shouldPoll) {
- if (!isPollerRunning) {
+ await initializeExistingResources();
+
+ if (!pollerState.value.isPollerRunning) {
resourcePoller.start();
- isPollerRunning = true;
+ pollerState.value.isPollerRunning = true;
}
- // Do initial refresh only once when polling starts
- if (!hasInitialRefresh) {
- hasInitialRefresh = true;
- // Small delay to avoid race conditions with component initialization
+ if (!pollerState.value.hasInitialRefresh) {
+ pollerState.value.hasInitialRefresh = true;
setTimeout(async () => {
- await refreshAll();
+ await refreshResources(activeResources, { isManual: false });
}, 100);
}
- } else {
- // Stop the poller when creating or no resources to poll
- if (isPollerRunning) {
- resourcePoller.stop();
- isPollerRunning = false;
- }
+ } else if (pollerState.value.isPollerRunning) {
+ resourcePoller.stop();
+ pollerState.value.isPollerRunning = false;
}
});
const poller = {
- refreshResources,
- isRefreshing,
- lastRefreshTime,
+ refreshResources: (
+ resources?: ResourceType[],
+ optionsOrForce?: { force?: boolean; isManual?: boolean } | boolean
+ ) => refreshResources(resources, optionsOrForce),
+ isRefreshing: computed(() => pollerState.value.isRefreshing),
+ lastRefreshTime: computed(() => pollerState.value.lastRefreshTime),
};
provide(KEY, poller);
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 691481cde9..7469cf2901 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -326,6 +326,7 @@
}
},
"task-run": {
+ "failed-runs": "Failed Tasks - Latest Execution Logs",
"history": "Execution History",
"latest-logs": "Latest Logs",
"status": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 99017fc806..aa8e1d7ca1 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -326,6 +326,7 @@
}
},
"task-run": {
+ "failed-runs": "Tareas fallidas: últimos registros de ejecución",
"history": "Historial de ejecución de tareas",
"latest-logs": "Últimos registros",
"status": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index a689013136..1d83852a5a 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -326,6 +326,7 @@
}
},
"task-run": {
+ "failed-runs": "失敗したタスク - 最新の実行ログ",
"history": "タスク実行履歴",
"latest-logs": "最新のログ",
"status": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 477f62a979..ee66b978a7 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -326,6 +326,7 @@
}
},
"task-run": {
+ "failed-runs": "Nhiệm vụ thất bại - Nhật ký thực thi mới nhất",
"history": "Lịch sử thực hiện nhiệm vụ",
"latest-logs": "Nhật ký mới nhất",
"status": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c2306ef346..92caff6e82 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -326,6 +326,7 @@
}
},
"task-run": {
+ "failed-runs": "失败的任务 - 最新的执行日志",
"history": "执行记录",
"latest-logs": "执行日志",
"status": {
diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
index 492b892db0..35cefabd2d 100644
--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
@@ -57,16 +57,6 @@
>
<InstanceV1Name :instance="database.instanceResource" />
</dd>
- <dt class="sr-only">{{ $t("common.project") }}</dt>
- <dd class="flex items-center text-sm md:mr-4">
- <span class="textlabel"
- >{{ $t("common.project") }}&nbsp;-&nbsp;</span
- >
- <ProjectV1Name
- :project="database.projectEntity"
- hash="#databases"
- />
- </dd>
<SQLEditorButtonV1
v-if="allowQuery"
class="text-sm md:mr-4"
@@ -222,7 +212,6 @@ import {
EnvironmentV1Name,
InstanceV1Name,
ProductionEnvironmentV1Icon,
- ProjectV1Name,
} from "@/components/v2";
import { CopyButton } from "@/components/v2";
import {