Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(rollout): simplify collapsed task item and optimize sheet loading (#18280)
boojack61497ee4bed4
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vueindex afca6e1c12..2097850950 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue@@ -19,20 +19,18 @@</div><!-- Task content -->- <div class="w-full" :class="isExpanded ? 'p-4 space-y-3' : 'py-3 px-4'">+ <div class="w-full" :class="isExpanded ? 'p-4 space-y-3' : 'py-2.5 px-4'"><!-- Header section -->- <div class="flex items-center justify-between gap-x-3 mb-2">+ <div+ class="flex items-center justify-between gap-x-3"+ :class="{ 'mb-2': isExpanded }"+ ><div class="flex items-center gap-x-2 flex-1 min-w-0">- <div- :class="readonly ? '' : 'cursor-pointer hover:opacity-80'"- class="transition-opacity"- >- <TaskStatus :status="task.status" :size="isExpanded ? 'large' : 'small'" />- </div>+ <TaskStatus :status="task.status" :size="isExpanded ? 'large' : 'small'" /><RouterLinkv-if="!readonly":to="`/${task.name}`"- class="transition-opacity shrink-0 hover:opacity-80"+ class="shrink-0 hover:opacity-80 transition-opacity"><DatabaseDisplay:database="task.target"@@ -40,31 +38,38 @@:link="false"/></RouterLink>- <div v-else class="shrink-0">- <DatabaseDisplay- :database="task.target"- :size="isExpanded ? 'large' : 'medium'"- :link="false"- />- </div>- <div v-if="!isExpanded" class="flex items-center gap-x-2 ml-auto shrink-0">- <NTag size="tiny" round class="opacity-80">+ <DatabaseDisplay+ v-else+ :database="task.target"+ :size="isExpanded ? 'large' : 'medium'"+ :link="false"+ class="shrink-0"+ />+ <!-- Collapsed view: contextual info + type -->+ <div v-if="!isExpanded" class="flex items-center gap-x-1.5 ml-auto shrink-0 text-xs text-gray-500">+ <!-- Status-contextual info first -->+ <template v-if="timingType === 'scheduled'">+ <ScheduledTimeIndicator+ :time="scheduledTime"+ :title="t('task.scheduled-time')"+ />+ <span class="text-gray-300">·</span>+ </template>+ <template v-else-if="timingType === 'running'">+ <span class="flex items-center gap-x-1 text-blue-600">+ <LoaderCircleIcon class="w-3 h-3 animate-spin" />+ {{ timingDisplay }}+ </span>+ <span class="text-gray-300">·</span>+ </template>+ <template v-else-if="collapsedContextInfo">+ <span>{{ collapsedContextInfo }}</span>+ <span class="text-gray-300">·</span>+ </template>+ <!-- Task type last -->+ <NTag round size="tiny" class="opacity-80">{{ taskTypeDisplay }}</NTag>- <!-- Scheduled time indicator -->- <ScheduledTimeIndicator- v-if="timingType === 'scheduled'"- :time="scheduledTime"- :title="t('task.scheduled-time')"- />- <!-- Running indicator -->- <span- v-else-if="timingType === 'running'"- class="flex items-center gap-x-1 text-xs text-yellow-600"- >- <LoaderCircleIcon class="w-3 h-3 animate-spin" />- {{ timingDisplay }}- </span></div></div>@@ -75,35 +80,22 @@:class="{ 'self-start': isExpanded }"@click.stop="emit('toggle-expand')">- <ChevronRightIcon v-if="!isExpanded" class="w-4 h-4 text-gray-600" />- <ChevronDownIcon v-else class="w-4 h-4 text-gray-600" />+ <ChevronRightIcon v-if="!isExpanded" class="w-4 h-4 text-gray-500" />+ <ChevronDownIcon v-else class="w-4 h-4 text-gray-500" /></button></div>- <!-- SQL preview - collapsed only -->- <div v-if="!isExpanded" class="space-y-1">- <div class="flex flex-row justify-start items-center gap-2">- <NTag size="tiny" round class="opacity-80">- {{ t("common.statement") }}- </NTag>- <div- class="text-xs text-gray-600 font-mono truncate min-w-0"- >- {{ statementPreview }}- </div>- </div>- <!-- Error preview for failed tasks -->- <div v-if="errorPreview" class="text-xs text-red-600 truncate pl-1">- {{ t("common.error") }}: {{ errorPreview }}- </div>- <!-- Skipped reason -->- <div v-if="task.status === Task_Status.SKIPPED && task.skippedReason" class="text-xs text-gray-500 italic truncate pl-1">- {{ task.skippedReason }}- </div>+ <!-- Collapsed: contextual status line (error/skip only) -->+ <div+ v-if="!isExpanded && collapsedStatusText"+ class="text-xs truncate mt-1"+ :class="task.status === Task_Status.FAILED ? 'text-red-600' : 'text-gray-500 italic'"+ >+ {{ collapsedStatusText }}</div><!-- Task metadata - expanded only -->- <div v-else class="space-y-3">+ <div v-if="isExpanded" class="space-y-3"><!-- Task information line with quick actions --><div class="flex items-center justify-between gap-x-2"><div class="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-gray-600">@@ -275,8 +267,9 @@ import TaskRolloutActionPanel from "@/components/Plan/components/RolloutView/Tasimport TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";import { taskRunNamePrefix } from "@/store";import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";-import { Task_Status, Task_Type } from "@/types/proto-es/v1/rollout_service_pb";+import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";import { useTaskActions } from "./composables/useTaskActions";+import { useTaskDisplay } from "./composables/useTaskDisplay";import { useTaskRunSummary } from "./composables/useTaskRunSummary";import { useTaskStatement } from "./composables/useTaskStatement";import { useTaskTiming } from "./composables/useTaskTiming";@@ -333,11 +326,10 @@ const handleActionConfirm = () => {events.emit("status-changed", { eager: true });};-const { loading, statementPreview, displayedStatement, isStatementTruncated } =- useTaskStatement(- () => props.task,- () => props.isExpanded- );+const { loading, displayedStatement, isStatementTruncated } = useTaskStatement(+ () => props.task,+ () => props.isExpanded+);const latestTaskRun = computed(() => {const taskRunsForTask = allTaskRuns.value.filter((run) =>@@ -362,75 +354,18 @@ const affectedRowsDisplay = computed(() => {return `${rows.toLocaleString()} row${rows === BigInt(1) ? "" : "s"}`;});-const taskTypeDisplay = computed(() => {- switch (props.task.type) {- case Task_Type.DATABASE_CREATE:- return t("task.type.database-create");- case Task_Type.DATABASE_MIGRATE:- return t("task.type.migrate");- case Task_Type.DATABASE_SDL:- return t("task.type.database-sdl");- case Task_Type.DATABASE_EXPORT:- return t("task.type.database-export");- case Task_Type.GENERAL:- return t("task.type.general");- default:- return "";- }-});--const errorPreview = computed(() => {- if (props.task.status !== Task_Status.FAILED) return "";- const detail = latestTaskRun.value?.detail || "";- const firstLine = detail.split("\n")[0];- const maxLength = 80;- return firstLine.length > maxLength- ? firstLine.substring(0, maxLength) + "..."- : firstLine;-});--const executorEmail = computed(() => {- const creator = latestTaskRun.value?.creator || "";- // Extract email from format: users/[email protected]- const match = creator.match(/users\/([^/]+)/);- return match?.[1] || "";-});--const resultSummary = computed(() => {- const taskRun = latestTaskRun.value;- if (!taskRun) return "";-- // For migrations and SDL, show schema version- if (taskRun.schemaVersion) {- return t("task.result.schema-version", { version: taskRun.schemaVersion });- }-- // For exports, show archive status- if (taskRun.exportArchiveStatus) {- return t("task.result.export-archive-ready");- }-- return "";-});--const waitingMessage = computed(() => {- const taskRun = latestTaskRun.value;- if (!taskRun || props.task.status !== Task_Status.PENDING) return "";-- const schedulerInfo = taskRun.schedulerInfo;- if (!schedulerInfo?.waitingCause) return "";-- const cause = schedulerInfo.waitingCause.cause;- if (cause.case === "connectionLimit") {- return t("task.waiting.connection-limit");- }- if (cause.case === "parallelTasksLimit") {- return t("task.waiting.parallel-tasks-limit");- }- if (cause.case === "task") {- return t("task.waiting.blocking-task");- }-- return "";-});+// Task display formatting (type, executor, messages, collapsed view info)+const {+ taskTypeDisplay,+ executorEmail,+ resultSummary,+ waitingMessage,+ collapsedContextInfo,+ collapsedStatusText,+} = useTaskDisplay(+ () => props.task,+ () => latestTaskRun.value,+ () => timingDisplay.value,+ () => affectedRowsDisplay.value+);</script>diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskList.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskList.vueindex 1551cac44d..7a32067e70 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskList.vue+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskList.vue@@ -106,10 +106,14 @@ const loadMoreTasks = () => {);};-// Prefetch sheets for visible tasks to improve performance-useSheetPreload(() => visibleTasks.value);+const { expandedTaskIds, isTaskExpanded, toggleExpand } =+ useTaskCollapse(filteredTasks);-const { isTaskExpanded, toggleExpand } = useTaskCollapse(filteredTasks);+// Prefetch sheets for expanded tasks only (statements not shown in collapsed view)+const expandedTasks = computed(() =>+ visibleTasks.value.filter((task) => expandedTaskIds.value.has(task.name))+);+useSheetPreload(() => expandedTasks.value);const {selectedTasks,diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useSheetPreload.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useSheetPreload.tsindex 1e2fcf9c2a..64447e8c67 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useSheetPreload.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useSheetPreload.ts@@ -4,7 +4,7 @@ import type { Task } from "@/types/proto-es/v1/rollout_service_pb";import { sheetNameOfTaskV1 } from "@/utils";/**- * Prefetches sheets for visible tasks in parallel to improve performance+ * Prefetches sheets for the given tasks in parallel.*/export const useSheetPreload = (tasks: () => Task[]) => {const sheetStore = useSheetV1Store();@@ -13,31 +13,30 @@ export const useSheetPreload = (tasks: () => Task[]) => {watch(tasks,(currentTasks) => {- const uniqueSheetNames = new Set<string>();-- // Extract all unique sheet names from tasks+ // Extract unique sheet names+ const sheetNames = new Set<string>();for (const task of currentTasks) {const sheetName = sheetNameOfTaskV1(task);if (sheetName) {- uniqueSheetNames.add(sheetName);+ sheetNames.add(sheetName);}}- // Only fetch sheets we haven't fetched yet- const newSheets = Array.from(uniqueSheetNames).filter(+ // Filter to only unfetched sheets+ const newSheets = Array.from(sheetNames).filter((name) => !fetchedSheets.value.has(name));- if (newSheets.length > 0) {- // Batch fetch new sheets in parallel- Promise.all(- newSheets.map((sheetName) =>- sheetStore.getOrFetchSheetByName(sheetName, "BASIC")- )- );+ if (newSheets.length === 0) return;++ // Batch fetch in parallel+ Promise.all(+ newSheets.map((name) => sheetStore.getOrFetchSheetByName(name, "BASIC"))+ );- // Mark these sheets as fetched- newSheets.forEach((name) => fetchedSheets.value.add(name));+ // Mark as fetched+ for (const name of newSheets) {+ fetchedSheets.value.add(name);}},{ immediate: true }diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskDisplay.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskDisplay.tsnew file mode 100644index 0000000000..c914c9be70--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskDisplay.ts@@ -0,0 +1,127 @@+import type { ComputedRef } from "vue";+import { computed } from "vue";+import { useI18n } from "vue-i18n";+import type { Task, TaskRun } from "@/types/proto-es/v1/rollout_service_pb";+import { Task_Status, Task_Type } from "@/types/proto-es/v1/rollout_service_pb";++const MAX_ERROR_PREVIEW_LENGTH = 100;++export interface UseTaskDisplayReturn {+ taskTypeDisplay: ComputedRef<string>;+ executorEmail: ComputedRef<string>;+ resultSummary: ComputedRef<string>;+ waitingMessage: ComputedRef<string>;+ collapsedContextInfo: ComputedRef<string>;+ collapsedStatusText: ComputedRef<string>;+}++/**+ * Composable for task display formatting.+ * Handles task type labels, executor info, and collapsed view display.+ */+export const useTaskDisplay = (+ task: () => Task,+ latestTaskRun: () => TaskRun | undefined,+ timingDisplay: () => string,+ affectedRowsDisplay: () => string+): UseTaskDisplayReturn => {+ const { t } = useI18n();++ const taskTypeDisplay = computed(() => {+ switch (task().type) {+ case Task_Type.DATABASE_CREATE:+ return t("task.type.database-create");+ case Task_Type.DATABASE_MIGRATE:+ return t("task.type.migrate");+ case Task_Type.DATABASE_SDL:+ return t("task.type.database-sdl");+ case Task_Type.DATABASE_EXPORT:+ return t("task.type.database-export");+ case Task_Type.GENERAL:+ return t("task.type.general");+ default:+ return "";+ }+ });++ const executorEmail = computed(() => {+ const creator = latestTaskRun()?.creator || "";+ const match = creator.match(/users\/([^/]+)/);+ return match?.[1] || "";+ });++ const resultSummary = computed(() => {+ const taskRun = latestTaskRun();+ if (!taskRun) return "";++ if (taskRun.schemaVersion) {+ return t("task.result.schema-version", {+ version: taskRun.schemaVersion,+ });+ }+ if (taskRun.exportArchiveStatus) {+ return t("task.result.export-archive-ready");+ }+ return "";+ });++ const waitingMessage = computed(() => {+ const taskRun = latestTaskRun();+ if (!taskRun || task().status !== Task_Status.PENDING) return "";++ const cause = taskRun.schedulerInfo?.waitingCause?.cause;+ if (!cause) return "";++ switch (cause.case) {+ case "connectionLimit":+ return t("task.waiting.connection-limit");+ case "parallelTasksLimit":+ return t("task.waiting.parallel-tasks-limit");+ case "task":+ return t("task.waiting.blocking-task");+ default:+ return "";+ }+ });++ // Collapsed view: contextual info (duration, affected rows for completed tasks)+ const collapsedContextInfo = computed(() => {+ if (task().status !== Task_Status.DONE) return "";++ const parts: string[] = [];+ if (timingDisplay()) parts.push(timingDisplay());+ if (affectedRowsDisplay()) parts.push(affectedRowsDisplay());+ return parts.join(" · ");+ });++ // Collapsed view: error or skip reason+ const collapsedStatusText = computed(() => {+ const currentTask = task();++ if (currentTask.status === Task_Status.FAILED) {+ const detail = latestTaskRun()?.detail || "";+ const firstLine = detail.split("\n")[0];+ return firstLine.length > MAX_ERROR_PREVIEW_LENGTH+ ? `${firstLine.substring(0, MAX_ERROR_PREVIEW_LENGTH)}...`+ : firstLine;+ }++ if (+ currentTask.status === Task_Status.SKIPPED &&+ currentTask.skippedReason+ ) {+ return currentTask.skippedReason;+ }++ return "";+ });++ return {+ taskTypeDisplay,+ executorEmail,+ resultSummary,+ waitingMessage,+ collapsedContextInfo,+ collapsedStatusText,+ };+};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskStatement.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskStatement.tsindex 6c1b240ef9..bb166d0328 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskStatement.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskStatement.ts@@ -3,15 +3,10 @@ import { useI18n } from "vue-i18n";import { useSheetV1Store } from "@/store";import type { Task } from "@/types/proto-es/v1/rollout_service_pb";import { getSheetStatement, sheetNameOfTaskV1 } from "@/utils";-import {- MAX_STATEMENT_DISPLAY_SIZE,- STATEMENT_PREVIEW_LENGTH,-} from "../constants";+import { MAX_STATEMENT_DISPLAY_SIZE } from "../constants";export interface UseTaskStatementReturn {loading: Ref<boolean>;- statement: Ref<string>;- statementPreview: ComputedRef<string>;displayedStatement: ComputedRef<string>;isStatementTruncated: ComputedRef<boolean>;}@@ -26,46 +21,35 @@ export const useTaskStatement = (const loading = ref(false);const statement = ref("");- // Load statement - uses cached version for collapsed view, lazy loads for expanded view+ // Only fetch statement when expanded (no preview needed for collapsed view)watchEffect(async () => {+ if (!isExpanded()) {+ // Skip fetching for collapsed tasks+ return;+ }+const sheetName = sheetNameOfTaskV1(task());if (!sheetName) {statement.value = "";return;}- // Check cache first for both expanded and collapsed views+ // Check cache firstconst cachedSheet = sheetStore.getSheetByName(sheetName);-if (cachedSheet) {- // Use cached statement immediatelystatement.value = getSheetStatement(cachedSheet);- } else if (isExpanded()) {- // Only fetch if expanded and not in cache- loading.value = true;- try {- await sheetStore.getOrFetchSheetByName(sheetName);- const sheet = sheetStore.getSheetByName(sheetName);- statement.value = sheet ? getSheetStatement(sheet) : "";- } finally {- loading.value = false;- }- } else {- // Collapsed and not in cache: show empty (will be loaded when expanded)- statement.value = "";+ return;}- });- // Preview for collapsed view (first line, truncated)- const statementPreview = computed(() => {- const stmt = statement.value;- if (!stmt) {- return t("rollout.task.no-statement");+ // Fetch if not in cache+ loading.value = true;+ try {+ await sheetStore.getOrFetchSheetByName(sheetName);+ const sheet = sheetStore.getSheetByName(sheetName);+ statement.value = sheet ? getSheetStatement(sheet) : "";+ } finally {+ loading.value = false;}- const firstLine = stmt.split("\n")[0];- return firstLine.length > STATEMENT_PREVIEW_LENGTH- ? firstLine.substring(0, STATEMENT_PREVIEW_LENGTH) + "..."- : firstLine;});// Check if statement exceeds display limit@@ -86,8 +70,6 @@ export const useTaskStatement = (return {loading,- statement,- statementPreview,displayedStatement,isStatementTruncated,};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskTiming.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskTiming.tsindex a79f3277f8..7706caee2e 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskTiming.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskTiming.ts@@ -2,14 +2,13 @@ import type { ComputedRef } from "vue";import { computed } from "vue";import type { Task, TaskRun } from "@/types/proto-es/v1/rollout_service_pb";import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";-import { formatDuration } from "./useTaskRunUtils";+import { getTaskRunDuration } from "./useTaskRunUtils";export type TimingType = "scheduled" | "running" | "completed" | "none";export interface UseTaskTimingReturn {timingDisplay: ComputedRef<string>;timingType: ComputedRef<TimingType>;- duration: ComputedRef<number | undefined>;scheduledTime: ComputedRef<Date | undefined>;}@@ -17,22 +16,6 @@ export const useTaskTiming = (task: () => Task,latestTaskRun: () => TaskRun | undefined): UseTaskTimingReturn => {- const duration = computed(() => {- const taskRun = latestTaskRun();- if (!taskRun) return undefined;-- const startTime = taskRun.startTime;- const updateTime = taskRun.updateTime;-- if (!startTime || !updateTime) {- return undefined;- }-- const startMs = Number(startTime.seconds) * 1000;- const updateMs = Number(updateTime.seconds) * 1000;- return updateMs - startMs;- });-const scheduledTime = computed(() => {const currentTask = task();if (currentTask.status === Task_Status.PENDING && currentTask.runTime) {@@ -57,10 +40,9 @@ export const useTaskTiming = (}if (- (status === Task_Status.DONE ||- status === Task_Status.FAILED ||- status === Task_Status.CANCELED) &&- duration.value !== undefined+ status === Task_Status.DONE ||+ status === Task_Status.FAILED ||+ status === Task_Status.CANCELED) {return "completed";}@@ -69,16 +51,9 @@ export const useTaskTiming = (});const timingDisplay = computed(() => {+ const taskRun = latestTaskRun();const type = timingType.value;- if (type === "completed" && duration.value !== undefined) {- return formatDuration(duration.value);- }-- if (type === "running" && duration.value !== undefined) {- return formatDuration(duration.value);- }-if (type === "scheduled" && scheduledTime.value) {return scheduledTime.value.toLocaleTimeString([], {hour: "2-digit",@@ -86,13 +61,17 @@ export const useTaskTiming = (});}+ // Use getTaskRunDuration for running and completed tasks+ if ((type === "running" || type === "completed") && taskRun) {+ return getTaskRunDuration(taskRun);+ }+return "";});return {timingDisplay,timingType,- duration,scheduledTime,};};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/constants.ts b/frontend/src/components/Plan/components/RolloutView/v2/constants.tsindex 7d3c6250af..8b05d91482 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/constants.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/constants.ts@@ -3,11 +3,6 @@*/export const DEFAULT_PAGE_SIZE = 10;-/**- * Maximum characters to show in collapsed SQL statement preview- */-export const STATEMENT_PREVIEW_LENGTH = 80;-/*** Maximum characters to display in expanded SQL statement view.* Larger statements are truncated to avoid performance issues with syntax highlighting.