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(frontend): clean up unused RolloutView components and improve task run log (#18385)
boojack88aa76059bf1
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vueindex bc7d432708..62ccf76918 100644--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue@@ -37,7 +37,7 @@ import { uniqueId } from "lodash-es";import { RefreshCcwIcon } from "lucide-vue-next";import { NButton, NTabPane, NTabs } from "naive-ui";import { computed, reactive, ref, watch } from "vue";-import TaskRunLogViewer from "@/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vue";+import { TaskRunLogViewer } from "@/components/Plan/components/RolloutView/v2/TaskRunLogViewer";import { rolloutServiceClientConnect } from "@/grpcweb";import { useSheetV1Store } from "@/store";import { Engine } from "@/types/proto-es/v1/common_pb";diff --git a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue b/frontend/src/components/Plan/components/RolloutView/RolloutView.vuedeleted file mode 100644index 627674052b..0000000000--- a/frontend/src/components/Plan/components/RolloutView/RolloutView.vue+++ /dev/null@@ -1,129 +0,0 @@-<template>- <div class="w-full h-full flex flex-col">- <!-- Content area -->- <div class="w-full flex-1 p-4">- <div v-if="!ready" class="flex items-center justify-center py-12">- <BBSpin class="w-6 h-6 text-primary" />- </div>- <div- v-else-if="mergedStages.length === 0"- class="flex items-center justify-center py-12"- >- <div class="flex flex-col items-center gap-4 max-w-md text-center">- <div- class="w-16 h-16 rounded-full bg-gray-100 flex items-center justify-center"- >- <LayersIcon class="w-8 h-8 text-gray-400" />- </div>- <div class="flex flex-col gap-y-2">- <h3 class="font-medium text-xl text-gray-900">- {{ $t("rollout.stage.no-stages.self") }}- </h3>- <p class="text-base text-gray-500">- {{ $t("rollout.stage.no-stages.description") }}- </p>- </div>- </div>- </div>- <template v-else>- <StagesView- :rollout="rollout"- :merged-stages="mergedStages"- @run-tasks="handleRunTasks"- @create-rollout-to-stage="handleCreateRolloutToStage"- />- </template>-- <!-- Rollback Section -->- <TaskRunRollbackSection :rollout="rollout" />- </div>-- <!-- Task Rollout Action Panel -->- <TaskRolloutActionPanel- v-if="runTasksPanel.show && runTasksPanel.target"- :show="runTasksPanel.show"- action="RUN"- :target="runTasksPanel.target"- @confirm="handleTaskActionPanelConfirm"- @close="handleTaskActionPanelClose"- />- </div>-</template>--<script setup lang="ts">-import { create } from "@bufbuild/protobuf";-import { LayersIcon } from "lucide-vue-next";-import { ref } from "vue";-import { useI18n } from "vue-i18n";-import { BBSpin } from "@/bbkit";-import { rolloutServiceClientConnect } from "@/grpcweb";-import { pushNotification, useCurrentProjectV1 } from "@/store";-import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";-import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";-import { usePlanContextWithRollout } from "../../logic";-import { useRolloutViewContext } from "./context";-import StagesView from "./StagesView.vue";-import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";-import TaskRunRollbackSection from "./TaskRunRollbackSection.vue";--const { t } = useI18n();-const { project } = useCurrentProjectV1();-const { events } = usePlanContextWithRollout();-const { rollout, mergedStages, ready } = useRolloutViewContext();--const runTasksPanel = ref<{- show: boolean;- target?: { type: "tasks"; stage: Stage; tasks: Task[] };-}>({- show: false,-});--const handleRunTasks = (stage: Stage, tasks: Task[]) => {- runTasksPanel.value = {- show: true,- target: { type: "tasks", stage, tasks },- };-};--const handleCreateRolloutToStage = async (stage: Stage) => {- try {- const request = create(CreateRolloutRequestSchema, {- parent: project.value.name,- rollout: {- plan: rollout.value.plan,- },- target: stage.environment,- });- await rolloutServiceClientConnect.createRollout(request);-- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.success"),- description: t("common.created"),- });-- // Trigger immediate refresh of rollout data- events.emit("status-changed", { eager: true });- } catch (error) {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("common.error"),- description: String(error),- });- }-};--const handleTaskActionPanelConfirm = () => {- // Refresh the rollout data after task action is confirmed.- events.emit("status-changed", { eager: true });- handleTaskActionPanelClose();-};--const handleTaskActionPanelClose = () => {- runTasksPanel.value = {- show: false,- };-};-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/StageActions.vue b/frontend/src/components/Plan/components/RolloutView/StageActions.vuedeleted file mode 100644index 62fd0b6913..0000000000--- a/frontend/src/components/Plan/components/RolloutView/StageActions.vue+++ /dev/null@@ -1,54 +0,0 @@-<template>- <template v-if="isCreated && runableTasks.length > 0">- <NButton- size="small"- :disabled="!canRunTasks"- @click.stop="$emit('run-tasks')"- >- <template #icon>- <PlayIcon />- </template>- {{ $t("common.run") }}- </NButton>- </template>- <template v-else-if="!isCreated && canCreateRollout">- <NPopconfirm- :negative-text="null"- :positive-text="$t('common.confirm')"- @positive-click="$emit('create-rollout')"- >- <template #trigger>- <NTooltip>- <template #trigger>- <NButton :size="'small'">- <template #icon>- <CircleFadingPlusIcon class="w-5 h-5" />- </template>- {{ $t("common.start") }}- </NButton>- </template>- {{ $t("rollout.stage.start-stage") }}- </NTooltip>- </template>- {{ $t("common.confirm-and-add") }}- </NPopconfirm>- </template>-</template>--<script setup lang="ts">-import { CircleFadingPlusIcon, PlayIcon } from "lucide-vue-next";-import { NButton, NPopconfirm, NTooltip } from "naive-ui";-import type { Task } from "@/types/proto-es/v1/rollout_service_pb";--defineProps<{- isCreated: boolean;- runableTasks: Task[];- canRunTasks: boolean;- canCreateRollout: boolean;-}>();--defineEmits<{- (event: "run-tasks"): void;- (event: "create-rollout"): void;-}>();-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vuedeleted file mode 100644index b1fffc7e76..0000000000--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue+++ /dev/null@@ -1,429 +0,0 @@-<template>- <div class="relative w-full flex items-center gap-4">- <!-- Stage card -->- <div- class="flex-1 bg-white rounded-lg border p-4 shadow-xs"- :class="- twMerge(- isCreated- ? 'border-gray-200 cursor-pointer hover:shadow-md transition-shadow'- : 'border-gray-300 border-dashed'- )- "- @click="isCreated && handleClickStageTitle()"- >- <div- class="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2 sm:gap-4"- >- <!-- Top/Left section: Stage info -->- <div class="flex items-start justify-between gap-2">- <!-- Stage title and status -->- <div class="flex items-start gap-2">- <TaskStatus :status="stageStatus" size="medium" />- <div class="flex flex-col gap-1">- <h3 class="text-base font-medium text-gray-900 truncate">- <EnvironmentV1Name- class="inline-block sm:w-24"- :environment="environment"- :link="false"- :null-environment-placeholder="'Null'"- />- </h3>- <Timestamp- v-if="latestUpdateTimestamp"- :timestamp="latestUpdateTimestamp"- />- </div>- </div>-- <!-- Mobile action buttons -->- <div class="sm:hidden flex items-center">- <StageActions- :is-created="isCreated"- :runable-tasks="runableTasks"- :can-run-tasks="canRunTasks"- :can-create-rollout="canRunTasks"- @run-tasks="handleRunAllTasks"- @create-rollout="createRolloutToStage"- />- </div>- </div>-- <!-- Bottom/Center section: Tasks -->- <div v-if="isCreated" class="flex flex-col sm:flex-1">- <!-- Task status counts -->- <div class="flex items-center gap-2 flex-wrap">- <template v-for="status in TASK_STATUS_FILTERS" :key="status">- <NTag- v-if="getTaskCount(status) > 0"- round- size="medium"- :type="- status === Task_Status.RUNNING- ? 'info'- : status === Task_Status.FAILED- ? 'error'- : 'default'- "- class="cursor-pointer hover:opacity-80 transition-opacity"- @click.stop="handleTaskStatusClick(status)"- >- <template #avatar>- <TaskStatus :status="status" size="small" disabled />- </template>- <div class="flex flex-row items-center gap-2">- <span class="select-none text-base">{{- stringifyTaskStatus(status)- }}</span>- <span class="select-none text-base font-medium">{{- getTaskCount(status)- }}</span>- </div>- </NTag>- </template>- <!-- Toggle button for tasks -->- <NButton- v-if="filteredTasks.length > 0"- quaternary- round- size="small"- class="px-2!"- @click.stop="showTasks = !showTasks"- >- <template #icon>- <ChevronDownIcon v-if="!showTasks" class="text-gray-500" />- <ChevronUpIcon v-else class="text-gray-500" />- </template>- </NButton>- </div>- <!-- Tasks -->- <div- v-if="filteredTasks.length > 0 && showTasks"- class="mt-2 flex flex-row gap-2 flex-wrap"- >- <NTag- v-for="task in displayedTasks"- :key="task.name"- round- size="small"- :bordered="false"- @click.stop="handleTaskClick(task)"- >- <template #avatar>- <TaskStatus :status="task.status" size="tiny" disabled />- </template>- <div class="flex items-center flex-nowrap gap-2">- <DatabaseDisplay :database="task.target" />- <template v-if="task.runTime && task.status === Task_Status.PENDING">- <span class="font-mono text-control-light opacity-80">/</span>- <NTooltip>- <template #trigger>- <div class="flex items-center gap-1">- <CalendarClockIcon- :size="14"- class="text-control-light"- />- <span class="text-control">{{- humanizeTs(- getTimeForPbTimestampProtoEs(task.runTime, 0) / 1000- )- }}</span>- </div>- </template>- <div class="flex flex-col gap-y-1">- <div class="text-sm opacity-80">- {{ $t("task.scheduled-time") }}- </div>- <div class="text-sm whitespace-nowrap">- {{ formatFullDateTime(task.runTime) }}- </div>- </div>- </NTooltip>- </template>- </div>- </NTag>- <NTag- v-if="remainingTaskCount > 0"- round- size="small"- type="default"- :bordered="false"- class="opacity-80"- :class="isCreated && 'cursor-pointer hover:opacity-100'"- @click.stop="handleClickStageTitle()"- >- +{{ remainingTaskCount }} more- </NTag>- </div>- </div>-- <!-- Desktop action buttons -->- <div class="hidden sm:flex justify-end items-start">- <StageActions- :is-created="isCreated"- :runable-tasks="runableTasks"- :can-run-tasks="canRunTasks"- :can-create-rollout="canRunTasks"- @run-tasks="handleRunAllTasks"- @create-rollout="createRolloutToStage"- />- </div>- </div>- </div>- </div>-</template>--<script setup lang="ts">-import type { Timestamp as TimestampPb } from "@bufbuild/protobuf/wkt";-import dayjs from "dayjs";-import {- CalendarClockIcon,- ChevronDownIcon,- ChevronUpIcon,-} from "lucide-vue-next";-import { NButton, NTag, NTooltip } from "naive-ui";-import { twMerge } from "tailwind-merge";-import { computed, ref, watch } from "vue";-import { useRouter } from "vue-router";-import Timestamp from "@/components/misc/Timestamp.vue";-import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";-import { TASK_STATUS_FILTERS } from "@/components/Plan/constants/task";-import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";-import { EnvironmentV1Name } from "@/components/v2";-import {- PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,- PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,-} from "@/router/dashboard/projectV1";-import {- batchGetOrFetchDatabases,- useCurrentProjectV1,- useEnvironmentV1Store,-} from "@/store";-import { getTimeForPbTimestampProtoEs } from "@/types";-import type {- Rollout,- Stage,- Task,-} from "@/types/proto-es/v1/rollout_service_pb";-import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";-import {- extractProjectResourceName,- getStageStatus,- humanizeTs,- stringifyTaskStatus,-} from "@/utils";-import { usePlanContextWithRollout } from "../../logic";-import StageActions from "./StageActions.vue";-import { canRolloutTasks } from "./taskPermissions";--const props = defineProps<{- rollout: Rollout;- stage: Stage;- taskStatusFilter?: Task_Status[];- defaultShowTasks?: boolean;-}>();--const emit = defineEmits<{- (event: "run-tasks", stage: Stage, tasks: Task[]): void;- (event: "create-rollout-to-stage", stage: Stage): void;-}>();--const router = useRouter();-const { project } = useCurrentProjectV1();-const environmentStore = useEnvironmentV1Store();-const { readonly } = usePlanContextWithRollout();--const isCreated = computed(() => {- return props.rollout.stages.some(- (stage) => stage.environment === props.stage.environment- );-});--const environment = computed(() => {- return environmentStore.getEnvironmentByName(props.stage.environment);-});--// Toggle state for showing/hiding tasks - default based on parent coordination-const showTasks = ref(props.defaultShowTasks || false);--const filteredTasks = computed(() => {- let tasks = props.stage.tasks;-- // Apply status filter if provided- if (props.taskStatusFilter && props.taskStatusFilter.length > 0) {- tasks = tasks.filter((task) =>- props.taskStatusFilter!.includes(task.status)- );- }-- // Sort tasks by status order defined in TASK_STATUS_FILTERS- const statusOrder = new Map<Task_Status, number>();- TASK_STATUS_FILTERS.forEach((status, index) => {- statusOrder.set(status, index);- });-- return tasks.slice().sort((a, b) => {- const aOrder = statusOrder.get(a.status) ?? Number.MAX_SAFE_INTEGER;- const bOrder = statusOrder.get(b.status) ?? Number.MAX_SAFE_INTEGER;- return aOrder - bOrder;- });-});--// The maximum number of tasks to display before showing "more".-const MAX_DISPLAYED_TASKS = 10;--const displayedTasks = computed(() => {- return filteredTasks.value.slice(0, MAX_DISPLAYED_TASKS);-});--const remainingTaskCount = computed(() => {- return Math.max(0, filteredTasks.value.length - MAX_DISPLAYED_TASKS);-});--const runableTasks = computed(() => {- return filteredTasks.value.filter(- (task) =>- task.status === Task_Status.NOT_STARTED ||- task.status === Task_Status.FAILED ||- task.status === Task_Status.CANCELED- );-});--const canRunTasks = computed(() => {- if (readonly.value) {- return false;- }- return canRolloutTasks(filteredTasks.value);-});--const stageStatus = computed(() => {- // Create a temporary stage object with filtered tasks for status calculation- const stageWithFilteredTasks = {- ...props.stage,- tasks: filteredTasks.value,- };- return getStageStatus(stageWithFilteredTasks);-});--const latestUpdateTimestamp = computed(() => {- let latestTimestamp: TimestampPb | undefined;-- for (const task of props.stage.tasks) {- if (task.updateTime) {- if (- !latestTimestamp ||- task.updateTime.seconds > latestTimestamp.seconds- ) {- latestTimestamp = task.updateTime;- }- }- }-- return latestTimestamp;-});--const formatFullDateTime = (timestamp: TimestampPb) => {- const timestampInMilliseconds = getTimeForPbTimestampProtoEs(timestamp, 0);- return dayjs(timestampInMilliseconds).local().format();-};--const getTaskCount = (status: Task_Status) => {- return filteredTasks.value.filter((task) => task.status === status).length;-};--const handleRunAllTasks = () => {- emit("run-tasks", props.stage, runableTasks.value);-};--const createRolloutToStage = () => {- emit("create-rollout-to-stage", props.stage);-};--const handleClickStageTitle = () => {- // Only navigate if the stage is created- if (!isCreated.value) return;-- const rolloutId = props.rollout.name.split("/").pop();- const stageId = props.stage.name.split("/").pop();-- if (!rolloutId) return;-- // Navigate to the stage detail route- router.push({- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,- params: {- projectId: extractProjectResourceName(project.value.name),- rolloutId,- stageId: stageId || "_", // Use placeholder for empty stageId- },- });-};--const handleTaskStatusClick = (status: Task_Status) => {- // Only navigate if the stage is created- if (!isCreated.value) return;-- const rolloutId = props.rollout.name.split("/").pop();- const stageId = props.stage.name.split("/").pop();-- if (!rolloutId) return;-- // Navigate to the stage detail route with task status filter- router.push({- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL,- params: {- projectId: extractProjectResourceName(project.value.name),- rolloutId,- stageId: stageId || "_", // Use placeholder for empty stageId- },- query: {- taskStatus: Task_Status[status],- },- });-};--const handleTaskClick = (task: Task) => {- // Only navigate if the stage is created- if (!isCreated.value) return;-- const rolloutId = props.rollout.name.split("/").pop();- const stageId = props.stage.name.split("/").pop();- const taskId = task.name.split("/").pop();-- if (!rolloutId || !taskId) return;-- // Navigate to the task detail route- router.push({- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL_TASK_DETAIL,- params: {- projectId: extractProjectResourceName(project.value.name),- rolloutId,- stageId: stageId || "_", // Use placeholder for empty stageId- taskId,- },- });-};--const prepareDatabases = async () => {- // Only load data when tasks are shown- if (!showTasks.value) return;-- if (displayedTasks.value.length > 0) {- try {- await batchGetOrFetchDatabases(- displayedTasks.value.map((task) => task.target)- );- } catch {- // Ignore errors - this is just for pre-loading data- }- }-};--watch(- showTasks,- () => {- prepareDatabases();- },- { immediate: true }-);-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/StageView.vue b/frontend/src/components/Plan/components/RolloutView/StageView.vuedeleted file mode 100644index 05b8226e76..0000000000--- a/frontend/src/components/Plan/components/RolloutView/StageView.vue+++ /dev/null@@ -1,80 +0,0 @@-<template>- <div v-if="stage" class="w-full h-full flex flex-col">- <div class="px-4">- <div class="w-full flex flex-row pt-2 gap-2">- <NTag round>{{ $t("common.stage") }}</NTag>- <span class="font-medium text-lg">- <EnvironmentV1Name- :environment="- environmentStore.getEnvironmentByName(stage.environment)- "- :null-environment-placeholder="'Null'"- :link="false"- />- </span>-- <TaskFilter- :rollout="rollout"- :task-status-list="taskStatusFilter"- :stage="stage"- @update:task-status-list="taskStatusFilter = $event"- />- </div>- </div>-- <!-- Tasks Table View -->- <div class="flex-1 min-h-0">- <TaskTableView :task-status-filter="taskStatusFilter" :stage="stage" />- </div>- </div>-</template>--<script setup lang="ts">-import { NTag } from "naive-ui";-import { computed, ref, watch } from "vue";-import { useRoute } from "vue-router";-import { EnvironmentV1Name } from "@/components/v2";-import { useEnvironmentV1Store } from "@/store";-import type { Stage } from "@/types/proto-es/v1/rollout_service_pb";-import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";-import { usePlanContextWithRollout } from "../../logic";-import TaskFilter from "./TaskFilter.vue";-import TaskTableView from "./TaskTableView.vue";--const props = defineProps<{- rolloutId: string;- stageId: string;-}>();--const route = useRoute();-const environmentStore = useEnvironmentV1Store();-const { rollout } = usePlanContextWithRollout();--const stage = computed(() => {- return rollout.value.stages.find((s) => s.id === props.stageId) as Stage;-});--const taskStatusFilter = ref<Task_Status[]>([]);--// Watch for query parameter changes-watch(- () => route.query.taskStatus,- (taskStatus) => {- if (taskStatus && typeof taskStatus === "string") {- // Find the Task_Status enum value from the string- const statusValue = Object.entries(Task_Status).find(- ([key]) => key === taskStatus- )?.[1];-- if (statusValue !== undefined && typeof statusValue === "number") {- taskStatusFilter.value = [statusValue as Task_Status];- } else {- taskStatusFilter.value = [];- }- } else {- taskStatusFilter.value = [];- }- },- { immediate: true }-);-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/StagesView.vue b/frontend/src/components/Plan/components/RolloutView/StagesView.vuedeleted file mode 100644index 114a87c8c0..0000000000--- a/frontend/src/components/Plan/components/RolloutView/StagesView.vue+++ /dev/null@@ -1,74 +0,0 @@-<template>- <div class="relative w-full flex flex-col items-stretch justify-start gap-6">- <!-- Connecting lines between stages -->- <div- v-if="mergedStages.length > 1"- class="absolute left-6 top-10 bottom-10 w-0.5 bg-gray-200 z-0"- ></div>-- <StageCard- v-for="stage in mergedStages"- :key="stage.name"- :rollout="rollout"- :stage="stage"- :task-status-filter="taskStatusFilter"- :default-show-tasks="defaultShowTasksStage === stage.name"- @run-tasks="(stage, tasks) => $emit('run-tasks', stage, tasks)"- @create-rollout-to-stage="- (stage) => $emit('create-rollout-to-stage', stage)- "- />- </div>-</template>--<script setup lang="ts">-import { computed } from "vue";-import type {- Rollout,- Stage,- Task,- Task_Status,-} from "@/types/proto-es/v1/rollout_service_pb";-import { Task_Status as TaskStatus } from "@/types/proto-es/v1/rollout_service_pb";-import StageCard from "./StageCard.vue";--const props = defineProps<{- rollout: Rollout;- mergedStages: Stage[];- taskStatusFilter?: Task_Status[];-}>();--defineEmits<{- (event: "run-tasks", stage: Stage, tasks: Task[]): void;- (event: "create-rollout-to-stage", stage: Stage): void;-}>();--// Determine which stage should show tasks by default-const defaultShowTasksStage = computed(() => {- // First, check if any stage has running tasks- const stageWithRunningTasks = props.mergedStages.find((stage) =>- stage.tasks.some((task) => task.status === TaskStatus.RUNNING)- );- if (stageWithRunningTasks) {- return stageWithRunningTasks.name;- }-- // If no running tasks, find the first stage with unfinished tasks- const firstUnfinishedStage = props.mergedStages.find((stage) =>- stage.tasks.some(- (task) =>- task.status !== TaskStatus.DONE &&- task.status !== TaskStatus.SKIPPED &&- task.status !== TaskStatus.CANCELED- )- );- if (firstUnfinishedStage) {- return firstUnfinishedStage.name;- }-- // If all stages are finished, show tasks for the last stage- return props.mergedStages.length > 0- ? props.mergedStages[props.mergedStages.length - 1].name- : null;-});-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue b/frontend/src/components/Plan/components/RolloutView/TaskFilter.vuedeleted file mode 100644index 75d10454f1..0000000000--- a/frontend/src/components/Plan/components/RolloutView/TaskFilter.vue+++ /dev/null@@ -1,76 +0,0 @@-<template>- <div class="flex flex-row gap-1 items-center">- <template v-for="status in TASK_STATUS_FILTERS" :key="status">- <NTag- v-if="getTaskCount(status) > 0"- round- checkable- :checked="taskStatusList.includes(status)"- @update:checked="- (checked) => {- emit(- 'update:taskStatusList',- checked- ? [...taskStatusList, status]- : taskStatusList.filter((s) => s !== status)- );- }- "- >- <template #avatar>- <TaskStatus :status="status" size="small" />- </template>- <div class="flex flex-row items-center gap-1">- <span class="select-none text-base">{{- stringifyTaskStatus(status)- }}</span>- <span class="select-none text-base font-medium">{{- getTaskCount(status)- }}</span>- </div>- </NTag>- </template>- </div>-</template>--<script lang="ts" setup>-import { flatten } from "lodash-es";-import { NTag } from "naive-ui";-import { computed } from "vue";-import { TASK_STATUS_FILTERS } from "@/components/Plan/constants/task";-import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";-import type {- Rollout,- Stage,- Task_Status,-} from "@/types/proto-es/v1/rollout_service_pb";-import { stringifyTaskStatus } from "@/utils";-import { useRolloutViewContext } from "./context";--const props = defineProps<{- rollout: Rollout;- taskStatusList: Task_Status[];- stage?: Stage;-}>();--const emit = defineEmits<{- (event: "update:taskStatusList", taskStatusList: Task_Status[]): void;-}>();--const { mergedStages } = useRolloutViewContext();--// Using unified task status filters from constants--const allTasks = computed(() => {- if (props.stage) {- // If a specific stage is provided, use only its tasks- return props.stage.tasks;- }- // Otherwise, use all tasks from all stages- return flatten(mergedStages.value.map((stage) => stage.tasks));-});--const getTaskCount = (status: Task_Status) => {- return allTasks.value.filter((task) => task.status === status).length;-};-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue b/frontend/src/components/Plan/components/RolloutView/TaskOperations.vuedeleted file mode 100644index 27d372aca5..0000000000--- a/frontend/src/components/Plan/components/RolloutView/TaskOperations.vue+++ /dev/null@@ -1,271 +0,0 @@-<template>- <NScrollbar x-scrollable>- <div- v-bind="$attrs"- class="text-sm flex flex-col lg:flex-row items-start lg:items-center bg-blue-100 py-3 px-4 text-main gap-y-2 gap-x-4"- >- <span class="whitespace-nowrap">{{- tasks.length > 0- ? $t("task.selected-n-tasks", { n: tasks.length })- : $t("task.no-tasks-selected")- }}</span>- <div class="flex items-center">- <template v-for="action in actions" :key="action.text">- <NTooltip- :disabled="!action.disabled || !action.tooltip(action.text)"- >- <template #trigger>- <NButton- quaternary- size="small"- type="primary"- :disabled="action.disabled || readonly"- @click="action.click"- >- <template #icon>- <component :is="action.icon" class="h-4 w-4" />- </template>- <span class="text-sm">{{ action.text }}</span>- </NButton>- </template>- <span class="w-56 text-sm">- {{ action.tooltip(action.text.toLowerCase()) }}- </span>- </NTooltip>- </template>- </div>- </div>- </NScrollbar>-- <!-- Task Rollout Action Panel -->- <template v-if="state.selectedAction && actionTarget">- <TaskRolloutActionPanel- :show="state.showActionPanel"- :action="state.selectedAction"- :target="actionTarget"- @confirm="handleActionPanelConfirm"- @close="handleActionPanelClose"- />- </template>-</template>--<script lang="ts" setup>-import { PlayIcon, SkipForwardIcon, XIcon } from "lucide-vue-next";-import { NButton, NScrollbar, NTooltip } from "naive-ui";-import type { VNode } from "vue";-import { computed, h, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { useCurrentUserV1 } from "@/store";-import { userNamePrefix } from "@/store/modules/v1/common";-import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";-import type {- Rollout,- Stage,- Task,-} from "@/types/proto-es/v1/rollout_service_pb";-import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";-import { usePlanContextWithRollout } from "../../logic";-import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";-import { canRolloutTasks } from "./taskPermissions";--interface TaskAction {- icon: VNode;- text: string;- disabled: boolean;- click: () => void;- tooltip: (action: string) => string;-}--interface LocalState {- showActionPanel: boolean;- selectedAction?: "RUN" | "SKIP" | "CANCEL";-}--const props = defineProps<{- tasks: Task[];- rollout: Rollout;- stage: Stage;-}>();--const emit = defineEmits<{- (event: "action-confirmed"): void;-}>();--const state = reactive<LocalState>({- showActionPanel: false,- selectedAction: undefined,-});--const { t } = useI18n();-const { readonly, issue } = usePlanContextWithRollout();-const currentUser = useCurrentUserV1();--// Action target for the panel-const actionTarget = computed(() => {- if (!state.selectedAction) {- return undefined;- }-- if (state.selectedAction === "CANCEL") {- // For cancel actions, we would need task runs, but for now we'll use tasks- return {- type: "tasks" as const,- tasks: props.tasks,- stage: props.stage,- };- } else {- return {- type: "tasks" as const,- tasks: props.tasks,- stage: props.stage,- };- }-});--// Check if tasks have the right status for each action-const hasRunnableTasks = computed(() => {- return props.tasks.some((task) =>- [- Task_Status.NOT_STARTED,- Task_Status.FAILED,- Task_Status.CANCELED,- ].includes(task.status)- );-});--const hasCancellableTasks = computed(() => {- return props.tasks.some((task) =>- [Task_Status.PENDING, Task_Status.RUNNING].includes(task.status)- );-});--const hasSkippableTasks = computed(() => {- return props.tasks.some((task) =>- [- Task_Status.NOT_STARTED,- Task_Status.FAILED,- Task_Status.CANCELED,- ].includes(task.status)- );-});--// Check if user has permission to perform task actions-const canPerformTaskActions = computed(() => {- if (readonly.value) {- return false;- }- return canRolloutTasks(props.tasks, issue.value);-});--const getDisabledTooltip = (_action: string) => {- if (props.tasks.length === 0) {- return t("task.no-tasks-selected");- }- if (!canPerformTaskActions.value) {- // Special message for data export issues when user is not the creator- if (- issue.value &&- issue.value.type === Issue_Type.DATABASE_EXPORT &&- issue.value.creator !== `${userNamePrefix}${currentUser.value.email}`- ) {- return t("task.data-export-creator-only");- }- return t("task.no-permission");- }- return "";-};--const actions = computed((): TaskAction[] => {- const resp: TaskAction[] = [];-- // Run action - always show- resp.push({- icon: h(PlayIcon),- text: t("common.run"),- disabled:- props.tasks.length === 0 ||- !hasRunnableTasks.value ||- !canPerformTaskActions.value,- click: () => {- state.selectedAction = "RUN";- state.showActionPanel = true;- },- tooltip: (action) => {- if (props.tasks.length === 0) {- return getDisabledTooltip(action);- }- if (!canPerformTaskActions.value) {- return getDisabledTooltip(action);- }- if (!hasRunnableTasks.value) {- return t("task.no-runnable-tasks");- }- return "";- },- });-- // Skip action - always show- resp.push({- icon: h(SkipForwardIcon),- text: t("common.skip"),- disabled:- props.tasks.length === 0 ||- !hasSkippableTasks.value ||- !canPerformTaskActions.value,- click: () => {- state.selectedAction = "SKIP";- state.showActionPanel = true;- },- tooltip: (action) => {- if (props.tasks.length === 0) {- return getDisabledTooltip(action);- }- if (!canPerformTaskActions.value) {- return getDisabledTooltip(action);- }- if (!hasSkippableTasks.value) {- return t("task.no-skippable-tasks");- }- return "";- },- });-- // Cancel action - always show- resp.push({- icon: h(XIcon),- text: t("common.cancel"),- disabled:- props.tasks.length === 0 ||- !hasCancellableTasks.value ||- !canPerformTaskActions.value,- click: () => {- state.selectedAction = "CANCEL";- state.showActionPanel = true;- },- tooltip: (action) => {- if (props.tasks.length === 0) {- return getDisabledTooltip(action);- }- if (!canPerformTaskActions.value) {- return getDisabledTooltip(action);- }- if (!hasCancellableTasks.value) {- return t("task.no-cancellable-tasks");- }- return "";- },- });-- return resp;-});--const handleActionPanelConfirm = () => {- emit("action-confirmed");- handleActionPanelClose();-};--const handleActionPanelClose = () => {- state.showActionPanel = false;- state.selectedAction = undefined;-};-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue b/frontend/src/components/Plan/components/RolloutView/TaskTableView.vuedeleted file mode 100644index 0fb0439e7c..0000000000--- a/frontend/src/components/Plan/components/RolloutView/TaskTableView.vue+++ /dev/null@@ -1,52 +0,0 @@-<template>- <div class="w-full flex flex-col mt-4">- <!-- Task Operations Bar -->- <TaskOperations- :tasks="selectedTasks"- :rollout="rollout"- :stage="props.stage"- @action-confirmed="handleTaskActionConfirmed"- />-- <!-- Task Table -->- <div class="flex-1 overflow-hidden">- <TaskTable- :task-status-filter="props.taskStatusFilter"- :selected-tasks="selectedTasks"- :tasks="props.stage.tasks"- :task-selectable="(task) => task.status !== Task_Status.DONE"- @update:selected-tasks="handleSelectedTasksUpdate"- />- </div>- </div>-</template>--<script setup lang="ts">-import { ref } from "vue";-import {- type Stage,- type Task,- Task_Status,-} from "@/types/proto-es/v1/rollout_service_pb";-import { usePlanContextWithRollout } from "../../logic";-import TaskOperations from "./TaskOperations.vue";-import TaskTable from "./TaskTable.vue";--const props = defineProps<{- taskStatusFilter: Task_Status[];- stage: Stage;-}>();--const { rollout, events } = usePlanContextWithRollout();-const selectedTasks = ref<Task[]>([]);--const handleSelectedTasksUpdate = (tasks: Task[]) => {- selectedTasks.value = tasks;-};--const handleTaskActionConfirmed = () => {- // Clear selection after action is confirmed.- selectedTasks.value = [];- events.emit("status-changed", { eager: true });-};-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/index.ts b/frontend/src/components/Plan/components/RolloutView/index.tsindex a5a840433f..631e94a991 100644--- a/frontend/src/components/Plan/components/RolloutView/index.ts+++ b/frontend/src/components/Plan/components/RolloutView/index.ts@@ -1,4 +1,3 @@-export { default as RolloutView } from "./RolloutView.vue";export { default as TaskView } from "./TaskView.vue";export { default as TaskRunTable } from "./TaskRunTable.vue";export { default as TaskStatusActions } from "./TaskStatusActions.vue";diff --git a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vueindex dfc8bdc133..4cfa6b81fc 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue+++ b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue@@ -76,7 +76,7 @@ import Timestamp from "@/components/misc/Timestamp.vue";import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";import type { TaskRunLogSummary } from "./composables/useTaskRunLogSummary";-import TaskRunLogViewer from "./TaskRunLogViewer.vue";+import { TaskRunLogViewer } from "./TaskRunLogViewer";// Typesinterface StatusConfig {diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vuedeleted file mode 100644index 7396b1467b..0000000000--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vue+++ /dev/null@@ -1,477 +0,0 @@-<template>- <div- v-if="sections.length > 0"- class="w-full font-mono text-xs bg-gray-50 border border-gray-200 overflow-hidden rounded"- >- <div- v-for="section in sections"- :key="section.id"- class="border-b border-gray-200 last:border-b-0"- >- <!-- Section Header -->- <div- class="flex items-center gap-x-2 px-3 py-1.5 bg-white hover:bg-gray-50 cursor-pointer select-none"- @click="toggleSection(section.id)"- >- <!-- Expand/Collapse Icon -->- <component- :is="expandedSections.has(section.id) ? ChevronDownIcon : ChevronRightIcon"- class="w-3.5 h-3.5 text-gray-400 shrink-0"- />- <!-- Status Icon -->- <component- :is="section.statusIcon"- class="w-3.5 h-3.5 shrink-0"- :class="[- section.statusClass,- { 'animate-spin': section.status === 'running' },- ]"- />- <!-- Section Title -->- <span class="text-gray-700">{{ section.label }}</span>- <!-- Entry Count -->- <span v-if="section.entryCount > 1" class="text-gray-400">- ({{ section.entryCount }})- </span>- <!-- Spacer -->- <span class="flex-1" />- <!-- Duration -->- <span v-if="section.duration" class="text-gray-500 tabular-nums">- {{ section.duration }}- </span>- </div>-- <!-- Section Content with Virtual Scroll -->- <NVirtualList- v-if="expandedSections.has(section.id)"- :items="section.items"- :item-size="ITEM_HEIGHT"- item-resizable- :style="{ maxHeight: `${MAX_VISIBLE_ITEMS * ITEM_HEIGHT}px` }"- class="bg-gray-50 border-t border-gray-100"- >- <template #default="{ item, index }">- <div- class="flex items-start gap-x-2 px-3 py-0.5 hover:bg-gray-100"- :class="{ 'border-t border-gray-100': index > 0 }"- >- <!-- Row Number -->- <span class="text-gray-300 w-6 text-right shrink-0 tabular-nums">- {{ index + 1 }}- </span>- <!-- Timestamp -->- <span class="text-gray-400 shrink-0 tabular-nums">- {{ item.time }}- </span>- <!-- Relative Time -->- <span- v-if="item.relativeTime"- class="text-gray-300 shrink-0 tabular-nums"- >- {{ item.relativeTime }}- </span>- <!-- Status Indicator -->- <span :class="item.levelClass" class="shrink-0">- {{ item.levelIndicator }}- </span>- <!-- Detail -->- <span :class="item.detailClass" class="break-all">- {{ item.detail }}- </span>- <!-- Affected Rows -->- <span- v-if="item.affectedRows !== undefined"- class="text-gray-400 shrink-0 ml-auto"- >- {{ item.affectedRows }} rows- </span>- </div>- </template>- </NVirtualList>- </div>- </div>-</template>--<script lang="ts" setup>-import type { Timestamp as PbTimestamp } from "@bufbuild/protobuf/wkt";-import {- CheckCircle2Icon,- ChevronDownIcon,- ChevronRightIcon,- CircleIcon,- LoaderCircleIcon,- XCircleIcon,-} from "lucide-vue-next";-import { NVirtualList } from "naive-ui";-import type { Component } from "vue";-import { computed, ref, watch } from "vue";-import { useI18n } from "vue-i18n";-import { getDateForPbTimestampProtoEs } from "@/types";-import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";-import {- TaskRunLogEntry_TaskRunStatusUpdate_Status,- TaskRunLogEntry_TransactionControl_Type,- TaskRunLogEntry_Type,-} from "@/types/proto-es/v1/rollout_service_pb";-import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";-import { extractSheetCommandByIndex } from "@/utils";--// Constants for virtual scroll-const ITEM_HEIGHT = 20; // px per row-const MAX_VISIBLE_ITEMS = 10; // Show max 10 items before scrolling--// Types-type SectionStatus = "success" | "error" | "running" | "pending";--interface DisplayItem {- key: string;- time: string;- relativeTime: string;- levelIndicator: string;- levelClass: string;- detail: string;- detailClass: string;- affectedRows?: number;-}--interface Section {- id: string; // Unique identifier for this section- type: TaskRunLogEntry_Type;- label: string;- status: SectionStatus;- statusIcon: Component;- statusClass: string;- duration: string;- entryCount: number;- items: DisplayItem[];-}--// Props-const props = defineProps<{- entries: TaskRunLogEntry[];- sheet?: Sheet;-}>();--const { t } = useI18n();--// Section labels-const getSectionLabel = (type: TaskRunLogEntry_Type): string => {- switch (type) {- case TaskRunLogEntry_Type.SCHEMA_DUMP:- return t("task-run.log-type.schema-dump");- case TaskRunLogEntry_Type.COMMAND_EXECUTE:- return t("task-run.log-type.command-execute");- case TaskRunLogEntry_Type.DATABASE_SYNC:- return t("task-run.log-type.database-sync");- case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE:- return t("task-run.log-type.status-update");- case TaskRunLogEntry_Type.TRANSACTION_CONTROL:- return t("task-run.log-type.transaction");- case TaskRunLogEntry_Type.PRIOR_BACKUP:- return t("task-run.log-type.prior-backup");- case TaskRunLogEntry_Type.RETRY_INFO:- return t("task-run.log-type.retry");- case TaskRunLogEntry_Type.COMPUTE_DIFF:- return t("task-run.log-type.compute-diff");- default:- return "Unknown";- }-};--// Status configuration-const STATUS_CONFIG: Record<SectionStatus, { icon: Component; class: string }> =- {- success: { icon: CheckCircle2Icon, class: "text-green-600" },- error: { icon: XCircleIcon, class: "text-red-600" },- running: { icon: LoaderCircleIcon, class: "text-blue-600" },- pending: { icon: CircleIcon, class: "text-gray-400" },- };--// Expanded sections state (keyed by section id)-const expandedSections = ref<Set<string>>(new Set());--const toggleSection = (sectionId: string) => {- if (expandedSections.value.has(sectionId)) {- expandedSections.value.delete(sectionId);- } else {- expandedSections.value.add(sectionId);- }- // Trigger reactivity- expandedSections.value = new Set(expandedSections.value);-};--// Timestamp utilities-const getTimestampMs = (ts: PbTimestamp | undefined): number => {- if (!ts) return 0;- return Number(ts.seconds) * 1000 + ts.nanos / 1000000;-};--const formatTime = (ts: PbTimestamp | undefined): string => {- if (!ts) return "--:--:--.---";- const date = getDateForPbTimestampProtoEs(ts);- if (!date) return "--:--:--.---";- return (- [- date.getHours().toString().padStart(2, "0"),- date.getMinutes().toString().padStart(2, "0"),- date.getSeconds().toString().padStart(2, "0"),- ].join(":") +- "." +- date.getMilliseconds().toString().padStart(3, "0")- );-};--const formatDuration = (ms: number): string => {- if (ms < 1000) return `${ms.toFixed(0)}ms`;- if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;- const mins = Math.floor(ms / 60000);- const secs = ((ms % 60000) / 1000).toFixed(0);- return `${mins}m ${secs}s`;-};--const formatRelativeTime = (ms: number): string => {- if (ms < 1000) return `+${ms.toFixed(0)}ms`;- return `+${(ms / 1000).toFixed(2)}s`;-};--// Entry analysis-const hasError = (entry: TaskRunLogEntry): boolean => {- switch (entry.type) {- case TaskRunLogEntry_Type.COMMAND_EXECUTE:- return !!entry.commandExecute?.response?.error;- case TaskRunLogEntry_Type.TRANSACTION_CONTROL:- return !!entry.transactionControl?.error;- case TaskRunLogEntry_Type.SCHEMA_DUMP:- return !!entry.schemaDump?.error;- case TaskRunLogEntry_Type.DATABASE_SYNC:- return !!entry.databaseSync?.error;- case TaskRunLogEntry_Type.PRIOR_BACKUP:- return !!entry.priorBackup?.error;- case TaskRunLogEntry_Type.COMPUTE_DIFF:- return !!entry.computeDiff?.error;- default:- return false;- }-};--const isComplete = (entry: TaskRunLogEntry): boolean => {- switch (entry.type) {- case TaskRunLogEntry_Type.COMMAND_EXECUTE:- return !!entry.commandExecute?.response;- case TaskRunLogEntry_Type.SCHEMA_DUMP:- return !!(entry.schemaDump?.startTime && entry.schemaDump?.endTime);- case TaskRunLogEntry_Type.DATABASE_SYNC:- return !!(entry.databaseSync?.startTime && entry.databaseSync?.endTime);- case TaskRunLogEntry_Type.PRIOR_BACKUP:- return !!(entry.priorBackup?.startTime && entry.priorBackup?.endTime);- case TaskRunLogEntry_Type.COMPUTE_DIFF:- return !!(entry.computeDiff?.startTime && entry.computeDiff?.endTime);- case TaskRunLogEntry_Type.TRANSACTION_CONTROL:- return true;- case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE:- return true;- case TaskRunLogEntry_Type.RETRY_INFO:- return true;- default:- return true;- }-};--// Get entry detail text-const getEntryDetail = (entry: TaskRunLogEntry): string => {- switch (entry.type) {- case TaskRunLogEntry_Type.COMMAND_EXECUTE: {- const cmd = entry.commandExecute;- if (!cmd) return "";- if (cmd.response?.error) return cmd.response.error;-- let statement: string | undefined;- if (cmd.statement) {- statement = cmd.statement;- } else if (cmd.commandIndexes.length > 0 && props.sheet) {- statement = extractSheetCommandByIndex(- props.sheet,- cmd.commandIndexes[0]- );- }- if (statement) {- const stmt = statement.trim().replace(/\s+/g, " ");- return stmt.length > 80 ? stmt.substring(0, 80) + "..." : stmt;- }- return "-";- }- case TaskRunLogEntry_Type.TRANSACTION_CONTROL: {- const txn = entry.transactionControl;- if (!txn) return "";- const typeLabels: Record<number, string> = {- [TaskRunLogEntry_TransactionControl_Type.BEGIN]: "BEGIN",- [TaskRunLogEntry_TransactionControl_Type.COMMIT]: "COMMIT",- [TaskRunLogEntry_TransactionControl_Type.ROLLBACK]: "ROLLBACK",- };- const typeStr = typeLabels[txn.type] ?? "";- return txn.error ? `${typeStr} error: ${txn.error}` : typeStr;- }- case TaskRunLogEntry_Type.SCHEMA_DUMP: {- const dump = entry.schemaDump;- if (!dump) return "";- if (dump.error) return dump.error;- if (dump.startTime && dump.endTime) return "completed";- return t("task-run.log-detail.dumping");- }- case TaskRunLogEntry_Type.DATABASE_SYNC: {- const sync = entry.databaseSync;- if (!sync) return "";- if (sync.error) return sync.error;- if (sync.startTime && sync.endTime) return "completed";- return t("task-run.log-detail.syncing");- }- case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE: {- const status = entry.taskRunStatusUpdate;- if (!status) return "";- switch (status.status) {- case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_WAITING:- return t("task-run.log-detail.waiting-to-execute");- case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_RUNNING:- return t("task-run.log-detail.executing");- default:- return t("task-run.log-detail.status-changed");- }- }- case TaskRunLogEntry_Type.PRIOR_BACKUP: {- const backup = entry.priorBackup;- if (!backup) return "";- if (backup.error) return backup.error;- const items = backup.priorBackupDetail?.items;- if (items?.length) {- return t("task-run.log-detail.backup-completed", {- count: items.length,- });- }- if (backup.startTime && backup.endTime) return "completed";- return t("task-run.log-detail.backing-up");- }- case TaskRunLogEntry_Type.RETRY_INFO: {- const retry = entry.retryInfo;- if (!retry) return "";- const attempt = t("task-run.log-detail.retry-attempt", {- current: retry.retryCount,- max: retry.maximumRetries,- });- return retry.error ? `${attempt} - ${retry.error}` : attempt;- }- case TaskRunLogEntry_Type.COMPUTE_DIFF: {- const diff = entry.computeDiff;- if (!diff) return "";- if (diff.error) return diff.error;- if (diff.startTime && diff.endTime) return "completed";- return t("task-run.log-detail.computing");- }- default:- return "";- }-};--// Group consecutive entries of the same type into sections (ordered by time)-const sections = computed((): Section[] => {- if (!props.entries.length) return [];-- // Sort entries by time first- const sortedEntries = [...props.entries].sort((a, b) => {- return getTimestampMs(a.logTime) - getTimestampMs(b.logTime);- });-- // Group consecutive entries of the same type- const groups: { type: TaskRunLogEntry_Type; entries: TaskRunLogEntry[] }[] =- [];- let currentGroup: {- type: TaskRunLogEntry_Type;- entries: TaskRunLogEntry[];- } | null = null;-- for (const entry of sortedEntries) {- if (currentGroup && currentGroup.type === entry.type) {- // Same type as current group - add to it- currentGroup.entries.push(entry);- } else {- // Different type - start a new group- currentGroup = { type: entry.type, entries: [entry] };- groups.push(currentGroup);- }- }-- // Build sections from groups- const result: Section[] = groups.map((group, groupIdx) => {- const { type, entries } = group;-- // Calculate section status- const hasAnyError = entries.some(hasError);- const allComplete = entries.every(isComplete);- let status: SectionStatus = "pending";- if (hasAnyError) {- status = "error";- } else if (allComplete) {- status = "success";- } else {- status = "running";- }-- // Calculate duration- const timestamps = entries- .map((e) => getTimestampMs(e.logTime))- .filter((t) => t > 0);- const startTime = timestamps.length ? Math.min(...timestamps) : 0;- const endTime = timestamps.length ? Math.max(...timestamps) : 0;- const durationMs = endTime - startTime;-- // Build display items- const items: DisplayItem[] = entries.map((entry, idx) => {- const entryTime = getTimestampMs(entry.logTime);- const relativeMs = startTime > 0 ? entryTime - startTime : 0;- const entryHasError = hasError(entry);-- return {- key: `${groupIdx}-${idx}`,- time: formatTime(entry.logTime),- relativeTime: relativeMs > 0 ? formatRelativeTime(relativeMs) : "",- levelIndicator: entryHasError ? "\u2717" : "\u2713",- levelClass: entryHasError ? "text-red-600" : "text-green-600",- detail: getEntryDetail(entry),- detailClass: entryHasError ? "text-red-700" : "text-gray-600",- affectedRows:- entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE- ? Number(entry.commandExecute?.response?.affectedRows ?? 0) ||- undefined- : undefined,- };- });-- const statusCfg = STATUS_CONFIG[status];- return {- id: `section-${groupIdx}`,- type,- label: getSectionLabel(type),- status,- statusIcon: statusCfg.icon,- statusClass: statusCfg.class,- duration: durationMs > 0 ? formatDuration(durationMs) : "",- entryCount: entries.length,- items,- };- });-- return result;-});--// Auto-expand error sections when sections change-watch(- sections,- (newSections) => {- for (const section of newSections) {- if (section.status === "error") {- expandedSections.value.add(section.id);- }- }- },- { immediate: true }-);-</script>diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vuenew file mode 100644index 0000000000..80e5e54d91--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vue@@ -0,0 +1,114 @@+<template>+ <div+ v-if="sections.length > 0"+ class="w-full font-mono text-xs bg-gray-50 border border-gray-200 overflow-hidden rounded"+ >+ <div+ v-for="section in sections"+ :key="section.id"+ class="border-b border-gray-200 last:border-b-0"+ >+ <!-- Section Header -->+ <div+ class="flex items-center gap-x-2 px-3 py-1.5 bg-white hover:bg-gray-50 cursor-pointer select-none"+ @click="toggleSection(section.id)"+ >+ <!-- Expand/Collapse Icon -->+ <component+ :is="isSectionExpanded(section.id) ? ChevronDownIcon : ChevronRightIcon"+ class="w-3.5 h-3.5 text-gray-400 shrink-0"+ />+ <!-- Status Icon -->+ <component+ :is="section.statusIcon"+ class="w-3.5 h-3.5 shrink-0"+ :class="[+ section.statusClass,+ { 'animate-spin': section.status === 'running' },+ ]"+ />+ <!-- Section Title -->+ <span class="text-gray-700">{{ section.label }}</span>+ <!-- Entry Count -->+ <span v-if="section.entryCount > 1" class="text-gray-400">+ ({{ section.entryCount }})+ </span>+ <!-- Spacer -->+ <span class="flex-1" />+ <!-- Duration -->+ <span v-if="section.duration" class="text-gray-500 tabular-nums">+ {{ section.duration }}+ </span>+ </div>++ <!-- Section Content with Virtual Scroll -->+ <NVirtualList+ v-if="isSectionExpanded(section.id)"+ :items="section.items"+ :item-size="ITEM_HEIGHT"+ item-resizable+ :style="{ maxHeight: `${MAX_VISIBLE_ITEMS * ITEM_HEIGHT}px` }"+ class="bg-gray-50 border-t border-gray-100"+ >+ <template #default="{ item, index }">+ <div+ class="flex items-start gap-x-2 px-3 py-0.5 hover:bg-gray-100"+ :class="{ 'border-t border-gray-100': index > 0 }"+ >+ <!-- Row Number -->+ <span class="text-gray-300 w-6 text-right shrink-0 tabular-nums">+ {{ index + 1 }}+ </span>+ <!-- Timestamp -->+ <span class="text-gray-400 shrink-0 tabular-nums">+ {{ item.time }}+ </span>+ <!-- Relative Time -->+ <span+ v-if="item.relativeTime"+ class="text-gray-300 shrink-0 tabular-nums"+ >+ {{ item.relativeTime }}+ </span>+ <!-- Status Indicator -->+ <span :class="item.levelClass" class="shrink-0">+ {{ item.levelIndicator }}+ </span>+ <!-- Detail -->+ <span :class="item.detailClass" class="break-all">+ {{ item.detail }}+ </span>+ <!-- Affected Rows -->+ <span+ v-if="item.affectedRows !== undefined"+ class="text-gray-400 shrink-0 ml-auto"+ >+ {{ item.affectedRows }} rows+ </span>+ </div>+ </template>+ </NVirtualList>+ </div>+ </div>+</template>++<script lang="ts" setup>+import { ChevronDownIcon, ChevronRightIcon } from "lucide-vue-next";+import { NVirtualList } from "naive-ui";+import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";+import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";+import { useTaskRunLogSections } from "./useTaskRunLogSections";++const ITEM_HEIGHT = 20;+const MAX_VISIBLE_ITEMS = 10;++const props = defineProps<{+ entries: TaskRunLogEntry[];+ sheet?: Sheet;+}>();++const { sections, toggleSection, isSectionExpanded } = useTaskRunLogSections(+ () => props.entries,+ () => props.sheet+);+</script>diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/index.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/index.tsnew file mode 100644index 0000000000..508972392f--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/index.ts@@ -0,0 +1,3 @@+export { default as TaskRunLogViewer } from "./TaskRunLogViewer.vue";+export * from "./types";+export * from "./useTaskRunLogSections";diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.tsnew file mode 100644index 0000000000..21932fc461--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.ts@@ -0,0 +1,32 @@+import type { Component } from "vue";+import type { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";++export type SectionStatus = "success" | "error" | "running" | "pending";++export interface DisplayItem {+ key: string;+ time: string;+ relativeTime: string;+ levelIndicator: string;+ levelClass: string;+ detail: string;+ detailClass: string;+ affectedRows?: number;+}++export interface Section {+ id: string;+ type: TaskRunLogEntry_Type;+ label: string;+ status: SectionStatus;+ statusIcon: Component;+ statusClass: string;+ duration: string;+ entryCount: number;+ items: DisplayItem[];+}++export interface EntryGroup {+ type: TaskRunLogEntry_Type;+ entries: import("@/types/proto-es/v1/rollout_service_pb").TaskRunLogEntry[];+}diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.tsnew file mode 100644index 0000000000..b827386aaf--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.ts@@ -0,0 +1,281 @@+import {+ CheckCircle2Icon,+ CircleIcon,+ LoaderCircleIcon,+ XCircleIcon,+} from "lucide-vue-next";+import type { Component, ComputedRef, MaybeRefOrGetter, Ref } from "vue";+import { computed, ref, toValue, watch } from "vue";+import { useI18n } from "vue-i18n";+import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";+import {+ TaskRunLogEntry_TaskRunStatusUpdate_Status,+ TaskRunLogEntry_TransactionControl_Type,+ TaskRunLogEntry_Type,+} from "@/types/proto-es/v1/rollout_service_pb";+import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";+import { extractSheetCommandByIndex } from "@/utils";+import { addToSet, deleteFromSet } from "../utils/reactivity";+import type { DisplayItem, Section, SectionStatus } from "./types";+import {+ formatDuration,+ formatRelativeTime,+ formatTime,+ getTimestampMs,+ groupEntriesByType,+ hasError,+ isComplete,+} from "./utils";++const STATUS_CONFIG: Record<SectionStatus, { icon: Component; class: string }> =+ {+ success: { icon: CheckCircle2Icon, class: "text-green-600" },+ error: { icon: XCircleIcon, class: "text-red-600" },+ running: { icon: LoaderCircleIcon, class: "text-blue-600" },+ pending: { icon: CircleIcon, class: "text-gray-400" },+ };++export interface UseTaskRunLogSectionsReturn {+ sections: ComputedRef<Section[]>;+ expandedSections: Ref<Set<string>>;+ toggleSection: (sectionId: string) => void;+ isSectionExpanded: (sectionId: string) => boolean;+}++export const useTaskRunLogSections = (+ entries: MaybeRefOrGetter<TaskRunLogEntry[]>,+ sheet: MaybeRefOrGetter<Sheet | undefined>+): UseTaskRunLogSectionsReturn => {+ const { t } = useI18n();++ const expandedSections = ref<Set<string>>(new Set());+ const userCollapsedSections = ref<Set<string>>(new Set());++ const getSectionLabel = (type: TaskRunLogEntry_Type): string => {+ const labelMap: Partial<Record<TaskRunLogEntry_Type, string>> = {+ [TaskRunLogEntry_Type.SCHEMA_DUMP]: t("task-run.log-type.schema-dump"),+ [TaskRunLogEntry_Type.COMMAND_EXECUTE]: t(+ "task-run.log-type.command-execute"+ ),+ [TaskRunLogEntry_Type.DATABASE_SYNC]: t(+ "task-run.log-type.database-sync"+ ),+ [TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE]: t(+ "task-run.log-type.status-update"+ ),+ [TaskRunLogEntry_Type.TRANSACTION_CONTROL]: t(+ "task-run.log-type.transaction"+ ),+ [TaskRunLogEntry_Type.PRIOR_BACKUP]: t("task-run.log-type.prior-backup"),+ [TaskRunLogEntry_Type.RETRY_INFO]: t("task-run.log-type.retry"),+ [TaskRunLogEntry_Type.COMPUTE_DIFF]: t("task-run.log-type.compute-diff"),+ };+ return labelMap[type] ?? "Unknown";+ };++ const getEntryDetail = (entry: TaskRunLogEntry): string => {+ switch (entry.type) {+ case TaskRunLogEntry_Type.COMMAND_EXECUTE: {+ const cmd = entry.commandExecute;+ if (!cmd) return "";+ if (cmd.response?.error) return cmd.response.error;++ let statement: string | undefined;+ if (cmd.statement) {+ statement = cmd.statement;+ } else if (cmd.commandIndexes.length > 0) {+ const sheetValue = toValue(sheet);+ if (sheetValue) {+ statement = extractSheetCommandByIndex(+ sheetValue,+ cmd.commandIndexes[0]+ );+ }+ }+ if (statement) {+ const stmt = statement.trim().replace(/\s+/g, " ");+ return stmt.length > 80 ? stmt.substring(0, 80) + "..." : stmt;+ }+ return "-";+ }+ case TaskRunLogEntry_Type.TRANSACTION_CONTROL: {+ const txn = entry.transactionControl;+ if (!txn) return "";+ const typeLabels: Record<number, string> = {+ [TaskRunLogEntry_TransactionControl_Type.BEGIN]: "BEGIN",+ [TaskRunLogEntry_TransactionControl_Type.COMMIT]: "COMMIT",+ [TaskRunLogEntry_TransactionControl_Type.ROLLBACK]: "ROLLBACK",+ };+ const typeStr = typeLabels[txn.type] ?? "";+ return txn.error ? `${typeStr} error: ${txn.error}` : typeStr;+ }+ case TaskRunLogEntry_Type.SCHEMA_DUMP: {+ const dump = entry.schemaDump;+ if (!dump) return "";+ if (dump.error) return dump.error;+ if (dump.startTime && dump.endTime) return "completed";+ return t("task-run.log-detail.dumping");+ }+ case TaskRunLogEntry_Type.DATABASE_SYNC: {+ const sync = entry.databaseSync;+ if (!sync) return "";+ if (sync.error) return sync.error;+ if (sync.startTime && sync.endTime) return "completed";+ return t("task-run.log-detail.syncing");+ }+ case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE: {+ const status = entry.taskRunStatusUpdate;+ if (!status) return "";+ switch (status.status) {+ case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_WAITING:+ return t("task-run.log-detail.waiting-to-execute");+ case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_RUNNING:+ return t("task-run.log-detail.executing");+ default:+ return t("task-run.log-detail.status-changed");+ }+ }+ case TaskRunLogEntry_Type.PRIOR_BACKUP: {+ const backup = entry.priorBackup;+ if (!backup) return "";+ if (backup.error) return backup.error;+ const items = backup.priorBackupDetail?.items;+ if (items?.length) {+ return t("task-run.log-detail.backup-completed", {+ count: items.length,+ });+ }+ if (backup.startTime && backup.endTime) return "completed";+ return t("task-run.log-detail.backing-up");+ }+ case TaskRunLogEntry_Type.RETRY_INFO: {+ const retry = entry.retryInfo;+ if (!retry) return "";+ const attempt = t("task-run.log-detail.retry-attempt", {+ current: retry.retryCount,+ max: retry.maximumRetries,+ });+ return retry.error ? `${attempt} - ${retry.error}` : attempt;+ }+ case TaskRunLogEntry_Type.COMPUTE_DIFF: {+ const diff = entry.computeDiff;+ if (!diff) return "";+ if (diff.error) return diff.error;+ if (diff.startTime && diff.endTime) return "completed";+ return t("task-run.log-detail.computing");+ }+ default:+ return "";+ }+ };++ const buildDisplayItems = (+ groupEntries: TaskRunLogEntry[],+ groupIdx: number,+ startTime: number+ ): DisplayItem[] => {+ return groupEntries.map((entry, idx) => {+ const entryTime = getTimestampMs(entry.logTime);+ const relativeMs = startTime > 0 ? entryTime - startTime : 0;+ const entryHasError = hasError(entry);++ return {+ key: `${groupIdx}-${idx}`,+ time: formatTime(entry.logTime),+ relativeTime: relativeMs > 0 ? formatRelativeTime(relativeMs) : "",+ levelIndicator: entryHasError ? "\u2717" : "\u2713",+ levelClass: entryHasError ? "text-red-600" : "text-green-600",+ detail: getEntryDetail(entry),+ detailClass: entryHasError ? "text-red-700" : "text-gray-600",+ affectedRows:+ entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE+ ? Number(entry.commandExecute?.response?.affectedRows ?? 0) ||+ undefined+ : undefined,+ };+ });+ };++ const calculateSectionStatus = (+ groupEntries: TaskRunLogEntry[]+ ): SectionStatus => {+ const hasAnyError = groupEntries.some(hasError);+ const allComplete = groupEntries.every(isComplete);++ if (hasAnyError) return "error";+ if (allComplete) return "success";+ return "running";+ };++ const sections = computed((): Section[] => {+ const entriesValue = toValue(entries);+ if (!entriesValue.length) return [];++ const groups = groupEntriesByType(entriesValue);++ return groups.map((group, groupIdx) => {+ const { type, entries: groupEntries } = group;++ const status = calculateSectionStatus(groupEntries);++ const timestamps = groupEntries+ .map((e) => getTimestampMs(e.logTime))+ .filter((t) => t > 0);+ const startTime = timestamps.length ? Math.min(...timestamps) : 0;+ const endTime = timestamps.length ? Math.max(...timestamps) : 0;+ const durationMs = endTime - startTime;++ const items = buildDisplayItems(groupEntries, groupIdx, startTime);+ const statusCfg = STATUS_CONFIG[status];++ return {+ id: `section-${groupIdx}`,+ type,+ label: getSectionLabel(type),+ status,+ statusIcon: statusCfg.icon,+ statusClass: statusCfg.class,+ duration: durationMs > 0 ? formatDuration(durationMs) : "",+ entryCount: groupEntries.length,+ items,+ };+ });+ });++ const toggleSection = (sectionId: string) => {+ if (expandedSections.value.has(sectionId)) {+ deleteFromSet(expandedSections, sectionId);+ addToSet(userCollapsedSections, sectionId);+ } else {+ addToSet(expandedSections, sectionId);+ deleteFromSet(userCollapsedSections, sectionId);+ }+ };++ const isSectionExpanded = (sectionId: string): boolean => {+ return expandedSections.value.has(sectionId);+ };++ // Auto-expand error sections (respecting user's manual collapse)+ watch(+ sections,+ (newSections) => {+ for (const section of newSections) {+ if (+ section.status === "error" &&+ !userCollapsedSections.value.has(section.id)+ ) {+ addToSet(expandedSections, section.id);+ }+ }+ },+ { immediate: true }+ );++ return {+ sections,+ expandedSections,+ toggleSection,+ isSectionExpanded,+ };+};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.tsnew file mode 100644index 0000000000..c889f2fdff--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.ts@@ -0,0 +1,106 @@+import type { Timestamp as PbTimestamp } from "@bufbuild/protobuf/wkt";+import { getDateForPbTimestampProtoEs } from "@/types";+import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";+import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";+import type { EntryGroup } from "./types";++// Timestamp utilities+export const getTimestampMs = (ts: PbTimestamp | undefined): number => {+ if (!ts) return 0;+ return Number(ts.seconds) * 1000 + ts.nanos / 1000000;+};++export const formatTime = (ts: PbTimestamp | undefined): string => {+ if (!ts) return "--:--:--.---";+ const date = getDateForPbTimestampProtoEs(ts);+ if (!date) return "--:--:--.---";+ return (+ [+ date.getHours().toString().padStart(2, "0"),+ date.getMinutes().toString().padStart(2, "0"),+ date.getSeconds().toString().padStart(2, "0"),+ ].join(":") ++ "." ++ date.getMilliseconds().toString().padStart(3, "0")+ );+};++export const formatDuration = (ms: number): string => {+ if (ms < 1000) return `${ms.toFixed(0)}ms`;+ if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;+ const mins = Math.floor(ms / 60000);+ const secs = ((ms % 60000) / 1000).toFixed(0);+ return `${mins}m ${secs}s`;+};++export const formatRelativeTime = (ms: number): string => {+ if (ms < 1000) return `+${ms.toFixed(0)}ms`;+ return `+${(ms / 1000).toFixed(2)}s`;+};++// Entry analysis+export const hasError = (entry: TaskRunLogEntry): boolean => {+ switch (entry.type) {+ case TaskRunLogEntry_Type.COMMAND_EXECUTE:+ return !!entry.commandExecute?.response?.error;+ case TaskRunLogEntry_Type.TRANSACTION_CONTROL:+ return !!entry.transactionControl?.error;+ case TaskRunLogEntry_Type.SCHEMA_DUMP:+ return !!entry.schemaDump?.error;+ case TaskRunLogEntry_Type.DATABASE_SYNC:+ return !!entry.databaseSync?.error;+ case TaskRunLogEntry_Type.PRIOR_BACKUP:+ return !!entry.priorBackup?.error;+ case TaskRunLogEntry_Type.COMPUTE_DIFF:+ return !!entry.computeDiff?.error;+ default:+ return false;+ }+};++export const isComplete = (entry: TaskRunLogEntry): boolean => {+ switch (entry.type) {+ case TaskRunLogEntry_Type.COMMAND_EXECUTE:+ return !!entry.commandExecute?.response;+ case TaskRunLogEntry_Type.SCHEMA_DUMP:+ return !!(entry.schemaDump?.startTime && entry.schemaDump?.endTime);+ case TaskRunLogEntry_Type.DATABASE_SYNC:+ return !!(entry.databaseSync?.startTime && entry.databaseSync?.endTime);+ case TaskRunLogEntry_Type.PRIOR_BACKUP:+ return !!(entry.priorBackup?.startTime && entry.priorBackup?.endTime);+ case TaskRunLogEntry_Type.COMPUTE_DIFF:+ return !!(entry.computeDiff?.startTime && entry.computeDiff?.endTime);+ case TaskRunLogEntry_Type.TRANSACTION_CONTROL:+ case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE:+ case TaskRunLogEntry_Type.RETRY_INFO:+ return true;+ default:+ return true;+ }+};++// Group consecutive entries of the same type+export const groupEntriesByType = (+ entries: TaskRunLogEntry[]+): EntryGroup[] => {+ if (!entries.length) return [];++ // Sort entries by time first+ const sortedEntries = [...entries].sort((a, b) => {+ return getTimestampMs(a.logTime) - getTimestampMs(b.logTime);+ });++ const groups: EntryGroup[] = [];+ let currentGroup: EntryGroup | null = null;++ for (const entry of sortedEntries) {+ if (currentGroup && currentGroup.type === entry.type) {+ currentGroup.entries.push(entry);+ } else {+ currentGroup = { type: entry.type, entries: [entry] };+ groups.push(currentGroup);+ }+ }++ return groups;+};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.tsindex 78be173e0f..9ca94809f1 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts@@ -21,11 +21,46 @@ export interface UseTaskRunLogSummaryReturn {isLoading: ComputedRef<boolean>;}+const EMPTY_SUMMARY: TaskRunLogSummary = {+ totalAffectedRows: BigInt(0),+ hasAffectedRows: false,+ entries: [],+};++const calculateSummary = (log: TaskRunLog | undefined): TaskRunLogSummary => {+ if (!log?.entries?.length) return EMPTY_SUMMARY;++ let totalAffectedRows = BigInt(0);+ let hasAffectedRows = false;++ for (const entry of log.entries) {+ if (entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {+ const affectedRows = entry.commandExecute?.response?.affectedRows;+ if (affectedRows !== undefined) {+ totalAffectedRows += affectedRows;+ hasAffectedRows = true;+ }+ }+ }++ return {+ totalAffectedRows,+ hasAffectedRows,+ entries: log.entries,+ };+};+/*** Composable for fetching and summarizing task run logs.- * Provides affected rows count and log entries.- * Data is cached in the store, so multiple calls with the same taskRun are efficient.- * Listens to poller's "resource-refresh-completed" event to refetch logs when taskRuns are updated.+ *+ * Features:+ * - Fetches logs when taskRun changes or shouldFetch becomes true+ * - Auto-refetches when taskRun status changes (to get final results)+ * - Auto-refetches when poller refreshes taskRuns+ * - Calculates total affected rows from command executions+ *+ * @param taskRun - The task run to fetch logs for+ * @param shouldFetch - Whether to actively fetch (e.g., only when UI is visible)*/export const useTaskRunLogSummary = (taskRun: MaybeRefOrGetter<TaskRun | undefined>,@@ -35,78 +70,62 @@ export const useTaskRunLogSummary = (const taskRunLogStore = useTaskRunLogStore();const isLoading = ref(false);- const fetchLog = async (- taskRunName: string,- options?: { skipCache?: boolean }- ) => {+ // Helper to get current values+ const getTaskRunName = () => toValue(taskRun)?.name;+ const canFetch = () => toValue(shouldFetch) && !!getTaskRunName();++ const fetchLog = async (skipCache = false) => {+ const taskRunName = getTaskRunName();+ if (!taskRunName) return;+isLoading.value = true;try {- await taskRunLogStore.fetchTaskRunLog(taskRunName, options);+ await taskRunLogStore.fetchTaskRunLog(taskRunName, { skipCache });} finally {isLoading.value = false;}};- // Initial fetch when taskRun changes+ // Fetch when taskRun name changes or shouldFetch becomes truewatch(- [() => toValue(taskRun)?.name, () => toValue(shouldFetch)],- async ([taskRunName, fetch]) => {- if (fetch && taskRunName) {- await fetchLog(taskRunName);- }+ [getTaskRunName, () => toValue(shouldFetch)],+ async ([taskRunName, fetch], [, oldFetch]) => {+ if (!fetch || !taskRunName) return;+ // Skip cache when transitioning to fetch mode (e.g., item expanded)+ const skipCache = !oldFetch && fetch;+ await fetchLog(skipCache);},{ immediate: true });- // Refetch logs when poller refreshes taskRuns (skip cache to get latest)+ // Refetch when taskRun status changes to get final results+ watch(+ () => toValue(taskRun)?.status,+ async (newStatus, oldStatus) => {+ if (newStatus !== oldStatus && canFetch()) {+ await fetchLog(true);+ }+ }+ );++ // Refetch when poller refreshes taskRunsconst unsubscribe = events.on("resource-refresh-completed",async ({ resources }) => {- const taskRunName = toValue(taskRun)?.name;- if (- resources.includes("taskRuns") &&- toValue(shouldFetch) &&- taskRunName- ) {- await fetchLog(taskRunName, { skipCache: true });+ if (resources.includes("taskRuns") && canFetch()) {+ await fetchLog(true);}});- onUnmounted(() => {- unsubscribe();- });+ onUnmounted(unsubscribe);const taskRunLog = computed(() => {- const run = toValue(taskRun);- if (!run?.name) return undefined;- return taskRunLogStore.getTaskRunLog(run.name);+ const name = getTaskRunName();+ return name ? taskRunLogStore.getTaskRunLog(name) : undefined;});- const summary = computed((): TaskRunLogSummary => {- const log = taskRunLog.value;- const result: TaskRunLogSummary = {- totalAffectedRows: BigInt(0),- hasAffectedRows: false,- entries: [],- };-- if (!log?.entries?.length) return result;-- result.entries = log.entries;-- for (const entry of log.entries) {- if (entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {- const affectedRows = entry.commandExecute?.response?.affectedRows;- if (affectedRows !== undefined) {- result.totalAffectedRows += affectedRows;- result.hasAffectedRows = true;- }- }- }-- return result;- });+ const summary = computed(() => calculateSummary(taskRunLog.value));return {taskRunLog,diff --git a/frontend/src/components/Plan/components/RolloutView/v2/utils/taskStatus.ts b/frontend/src/components/Plan/components/RolloutView/v2/utils/taskStatus.tsindex bcb01b1bbe..13052ec495 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/utils/taskStatus.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/utils/taskStatus.ts@@ -1,93 +1,75 @@import { TASK_STATUS_FILTERS } from "@/components/Plan/constants/task";+import { getTimeForPbTimestampProtoEs } from "@/types";import type { Task } from "@/types/proto-es/v1/rollout_service_pb";import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";/**- * Task statuses that are considered "unfinished"+ * Task statuses that are considered "actionable" - not yet completed successfully.+ * Used for filtering unfinished tasks and determining if bulk actions are available.*/-export const UNFINISHED_TASK_STATUSES: Task_Status[] = [+const ACTIONABLE_STATUSES = new Set<Task_Status>([Task_Status.NOT_STARTED,Task_Status.PENDING,Task_Status.RUNNING,Task_Status.FAILED,Task_Status.CANCELED,-];+]);/**- * Task statuses that allow task selection for bulk actions+ * Priority map for task status sorting.+ * Built from TASK_STATUS_FILTERS to maintain single source of truth.*/-export const SELECTABLE_TASK_STATUSES: Task_Status[] = [- Task_Status.NOT_STARTED,- Task_Status.PENDING,- Task_Status.RUNNING,- Task_Status.FAILED,- Task_Status.CANCELED,-];+const STATUS_PRIORITY = new Map<Task_Status, number>(+ TASK_STATUS_FILTERS.map((status, index) => [status, index])+);/**- * Check if a task is in an unfinished state+ * Check if a task status is actionable (not completed).*/-export const isTaskUnfinished = (task: Task): boolean => {- return UNFINISHED_TASK_STATUSES.includes(task.status);-};+const isActionableStatus = (status: Task_Status): boolean =>+ ACTIONABLE_STATUSES.has(status);/**- * Check if a task is selectable for bulk actions+ * Check if a task is in an unfinished/actionable state.*/-export const isTaskSelectable = (task: Task): boolean => {- return SELECTABLE_TASK_STATUSES.includes(task.status);-};+export const isTaskUnfinished = (task: Task): boolean =>+ isActionableStatus(task.status);/**- * Check if a task is running+ * Check if a task is selectable for bulk actions.+ * Currently same as unfinished - tasks that aren't done can be acted upon.*/-export const isTaskRunning = (task: Task): boolean => {- return task.status === Task_Status.RUNNING;-};+export const isTaskSelectable = (task: Task): boolean =>+ isActionableStatus(task.status);/**- * Create a Map of task status to sort priority based on TASK_STATUS_FILTERS order.- * This ensures a single source of truth for task ordering.- *- * @returns Map where keys are Task_Status and values are their sort priority (lower = higher priority)+ * Check if a task is currently running.*/-const createTaskStatusPriorityMap = (): Map<Task_Status, number> => {- const priorityMap = new Map<Task_Status, number>();- TASK_STATUS_FILTERS.forEach((status, index) => {- priorityMap.set(status, index);- });- return priorityMap;-};--/**- * Cached task status priority map- */-const taskStatusPriorityMap = createTaskStatusPriorityMap();+export const isTaskRunning = (task: Task): boolean =>+ task.status === Task_Status.RUNNING;/*** Get the sort priority for a task status.- * Lower values indicate higher priority in the display order.- *- * @param status - The task status- * @returns The sort priority (0-based index from TASK_STATUS_FILTERS)+ * Lower values = higher priority in display order.*/-export const getTaskStatusPriority = (status: Task_Status): number => {- return taskStatusPriorityMap.get(status) ?? Number.MAX_SAFE_INTEGER;-};+export const getTaskStatusPriority = (status: Task_Status): number =>+ STATUS_PRIORITY.get(status) ?? Number.MAX_SAFE_INTEGER;/**- * Comparator function for sorting tasks by status priority.- * Use with Array.sort() to order tasks according to TASK_STATUS_FILTERS.+ * Compare tasks for sorting: first by status priority, then by update time.+ * Tasks with same status are sorted most recently updated first.** @example- * const sortedTasks = tasks.slice().sort(compareTasksByStatus);- *- * @param a - First task to compare- * @param b - Second task to compare- * @returns Negative if a should come before b, positive if b should come before a, 0 if equal+ * const sorted = [...tasks].sort(compareTasksByStatus);*/export const compareTasksByStatus = (a: Task, b: Task): number => {- const priorityA = getTaskStatusPriority(a.status);- const priorityB = getTaskStatusPriority(b.status);- return priorityA - priorityB;+ // Primary: status priority (lower = first)+ const statusDiff =+ getTaskStatusPriority(a.status) - getTaskStatusPriority(b.status);+ if (statusDiff !== 0) return statusDiff;++ // Secondary: update time (newer = first)+ const timeA = getTimeForPbTimestampProtoEs(a.updateTime, 0);+ const timeB = getTimeForPbTimestampProtoEs(b.updateTime, 0);+ return timeB - timeA;};diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vueindex c66a527bd1..e912d9d0d0 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue@@ -1,5 +1,5 @@<template>- <div class="flex items-center">+ <div class="flex items-center" :class="(plan.issue || plan.rollout) && 'mt-3'"><NTabs:key="`${plan.specs.length}-${selectedSpec.id}`":value="selectedSpec.id"@@ -10,7 +10,7 @@><template #prefix><div class=""></div>- <div v-if="!plan.issue" class="pl-4 text-base font-medium">+ <div v-if="!plan.issue && !plan.rollout" class="pl-4 text-base font-medium">{{ $t("plan.navigator.changes") }}</div></template>diff --git a/frontend/src/components/Revision/RevisionDetailPanel.vue b/frontend/src/components/Revision/RevisionDetailPanel.vueindex bb0f356674..7eeec6e0cd 100644--- a/frontend/src/components/Revision/RevisionDetailPanel.vue+++ b/frontend/src/components/Revision/RevisionDetailPanel.vue@@ -61,7 +61,7 @@ import {} from "@/types/proto-es/v1/rollout_service_pb";import { extractIssueUID, getSheetStatement } from "@/utils";import HumanizeDate from "../misc/HumanizeDate.vue";-import TaskRunLogViewer from "../Plan/components/RolloutView/v2/TaskRunLogViewer.vue";+import { TaskRunLogViewer } from "../Plan/components/RolloutView/v2/TaskRunLogViewer";interface LocalState {loading: boolean;diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex a2aaafff23..bb935b2ccd 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -89,7 +89,6 @@"unassigned": "Unassigned","new": "New","add": "Add",- "confirm-and-add": "Confirm and add","confirm-and-update": "Confirm and update","query": "Query","transfer": "Transfer",@@ -230,7 +229,6 @@"errors": "Errors","removed": "Removed","submit": "Submit",- "start": "Start","draft": "Draft","import": "Import","hard-delete": {@@ -307,7 +305,6 @@"description": "Set a specific date and time for tasks to automatically start running. Useful for maintenance windows or off-peak hours."},"select-task": "Select task | Select tasks",- "selected-n-tasks": "{n} task selected | {n} tasks selected","no-tasks-selected": "No tasks selected","no-runnable-tasks": "No runnable tasks","no-skippable-tasks": "No skippable tasks",@@ -1218,14 +1215,10 @@},"stage": {"self": "Stage | Stages",- "start-stage": "Start stage","run-stage": "Run Stage","confirm-create": "Confirm to create tasks for this stage?","back-to-stage": "Back to Stage {stage}",- "no-stages": {- "self": "No stages",- "description": "No stages are defined for this rollout."- }+ "no-stages": {}},"task": {"selected-count": "{count} task selected | {count} tasks selected",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex cd8da00a3b..9e64ea3ebe 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -89,7 +89,6 @@"unassigned": "No asignado","new": "Nuevo","add": "Agregar",- "confirm-and-add": "Confirmar y agregar","confirm-and-update": "Confirmar y actualizar","query": "Consulta","transfer": "Transferir",@@ -230,7 +229,6 @@"errors": "Errores","removed": "Remoto","submit": "Entregar",- "start": "Comenzar","draft": "Borrador","import": "Importar","hard-delete": {@@ -307,7 +305,6 @@"description": "Establezca una fecha y hora específicas para que las tareas comiencen a ejecutarse automáticamente. Útil para periodos de mantenimiento o horas de baja demanda."},"select-task": "Seleccionar tarea | Seleccionar tareas",- "selected-n-tasks": "{n} tarea seleccionada | {n} tareas seleccionadas","no-tasks-selected": "No hay tareas seleccionadas","no-runnable-tasks": "No hay tareas ejecutables","no-skippable-tasks": "No hay tareas que se puedan omitir",@@ -1218,14 +1215,10 @@},"stage": {"self": "Escenario | Escenarios",- "start-stage": "Etapa de inicio","run-stage": "Etapa de ejecución","confirm-create": "¿Está seguro de que desea crear tareas para esta etapa?","back-to-stage": "Volver a la etapa {stage}",- "no-stages": {- "self": "Sin etapas",- "description": "No se definen etapas para este lanzamiento."- }+ "no-stages": {}},"task": {"selected-count": "{count} tarea seleccionada | {count} tareas seleccionadas",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 8e9e317c14..2ad690838b 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -89,7 +89,6 @@"unassigned": "割り当てられていない","new": "作成する","add": "追加",- "confirm-and-add": "確認して追加","confirm-and-update": "確認して更新する","query": "お問い合わせ","transfer": "移行",@@ -230,7 +229,6 @@"errors": "エラー","removed": "削除されました","submit": "提出する",- "start": "始める","draft": "下書き","import": "輸入","hard-delete": {@@ -307,7 +305,6 @@"description": "タスクを自動的に実行開始する日時を指定します。メンテナンス期間やオフピーク時に便利です。"},"select-task": "タスクを選択 | タスクを選択",- "selected-n-tasks": "{n} 個のタスクが選択されました | {n} 個のタスクが選択されました","no-tasks-selected": "タスクが選択されていません","no-runnable-tasks": "実行可能なタスクはありません","no-skippable-tasks": "スキップ可能なタスクはありません",@@ -1218,14 +1215,10 @@},"stage": {"self": "ステージ | ステージ",- "start-stage": "スタートステージ","run-stage": "ランステージ","confirm-create": "このステージのタスクを作成してもよろしいですか?","back-to-stage": "ステージに戻る {stage}",- "no-stages": {- "self": "ステージなし",- "description": "このロールアウトにはステージが定義されていません。"- }+ "no-stages": {}},"task": {"selected-count": "{count} 個のタスクが選択されました | {count} 個のタスクが選択されました",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 2e99f26b3d..56de71b76c 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -89,7 +89,6 @@"unassigned": "Chưa gán","new": "Mới","add": "Thêm",- "confirm-and-add": "Xác nhận và Thêm","confirm-and-update": "Xác nhận và Cập nhật","query": "Truy vấn","transfer": "Chuyển",@@ -230,7 +229,6 @@"errors": "Lỗi","removed": "LOẠI BỎ","submit": "Nộp",- "start": "Bắt đầu","draft": "Bản nháp","import": "Nhập khẩu","hard-delete": {@@ -307,7 +305,6 @@"description": "Đặt ngày và giờ cụ thể để các tác vụ tự động bắt đầu chạy. Hữu ích cho các khung giờ bảo trì hoặc ngoài giờ cao điểm."},"select-task": "Chọn nhiệm vụ | Chọn nhiệm vụ",- "selected-n-tasks": "{n} nhiệm vụ đã chọn | {n} nhiệm vụ đã chọn","no-tasks-selected": "Không có nhiệm vụ nào được chọn","no-runnable-tasks": "Không có tác vụ nào có thể chạy được","no-skippable-tasks": "Không có nhiệm vụ nào có thể bỏ qua",@@ -1218,14 +1215,10 @@},"stage": {"self": "Giai đoạn | Các giai đoạn",- "start-stage": "Giai đoạn bắt đầu","run-stage": "Chạy sân khấu","confirm-create": "Bạn có chắc chắn muốn tạo tác vụ cho giai đoạn này không?","back-to-stage": "Trở lại sân khấu {stage}",- "no-stages": {- "self": "Không có giai đoạn",- "description": "Không có giai đoạn nào được xác định cho lần triển khai này."- }+ "no-stages": {}},"task": {"selected-count": "{count} nhiệm vụ đã chọn | {count} nhiệm vụ đã chọn",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 5ac236138e..b5325bfc09 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -89,7 +89,6 @@"unassigned": "未指派","new": "创建","add": "添加",- "confirm-and-add": "确认并添加","confirm-and-update": "确认并更新","query": "查询","transfer": "转移",@@ -230,7 +229,6 @@"errors": "错误","removed": "已移除","submit": "提交",- "start": "开始","draft": "草稿","import": "导入","hard-delete": {@@ -307,7 +305,6 @@"description": "设置任务自动开始运行的特定时间。"},"select-task": "选择任务 | 选择任务",- "selected-n-tasks": "已选择 {n} 个任务","no-tasks-selected": "未选择任何任务","no-runnable-tasks": "没有可运行的任务","no-skippable-tasks": "没有可跳过的任务",@@ -1218,14 +1215,10 @@},"stage": {"self": "阶段 | 阶段",- "start-stage": "开始该阶段","run-stage": "运行阶段","confirm-create": "确定要为此阶段创建任务吗?","back-to-stage": "返回阶段 {stage}",- "no-stages": {- "self": "没有阶段",- "description": "本次发布任务未定义任何阶段。"- }+ "no-stages": {}},"task": {"selected-count": "已选择 {count} 个任务",