Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): group task run logs by deployment when server restarts (#18424)
boojack6f7c2c65fed4
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionContent.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionContent.vuenew file mode 100644index 0000000000..78e4200667--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionContent.vue@@ -0,0 +1,54 @@+<template>+ <NVirtualList+ :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 py-0.5 hover:bg-gray-100"+ :class="[indent ? 'px-6' : 'px-3', { 'border-t border-gray-100': index > 0 }]"+ >+ <span class="text-gray-300 w-6 text-right shrink-0 tabular-nums">+ {{ index + 1 }}+ </span>+ <span class="text-gray-400 shrink-0 tabular-nums">+ {{ item.time }}+ </span>+ <span+ v-if="item.relativeTime"+ class="text-gray-300 shrink-0 tabular-nums"+ >+ {{ item.relativeTime }}+ </span>+ <span :class="item.levelClass" class="shrink-0">+ {{ item.levelIndicator }}+ </span>+ <span :class="item.detailClass" class="break-all">+ {{ item.detail }}+ </span>+ <span+ v-if="item.affectedRows !== undefined"+ class="text-gray-400 shrink-0 ml-auto"+ >+ {{ item.affectedRows }} rows+ </span>+ </div>+ </template>+ </NVirtualList>+</template>++<script lang="ts" setup>+import { NVirtualList } from "naive-ui";+import type { Section } from "./types";++const ITEM_HEIGHT = 20;+const MAX_VISIBLE_ITEMS = 10;++defineProps<{+ section: Section;+ indent?: boolean;+}>();+</script>diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionHeader.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionHeader.vuenew file mode 100644index 0000000000..436d11c418--- /dev/null+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/SectionHeader.vue@@ -0,0 +1,40 @@+<template>+ <div+ class="flex items-center gap-x-2 py-1.5 bg-white hover:bg-gray-50 cursor-pointer select-none"+ :class="indent ? 'px-6' : 'px-3'"+ @click="$emit('toggle')"+ >+ <component+ :is="isExpanded ? ChevronDownIcon : ChevronRightIcon"+ class="w-3.5 h-3.5 text-gray-400 shrink-0"+ />+ <component+ :is="section.statusIcon"+ class="w-3.5 h-3.5 shrink-0"+ :class="[section.statusClass, { 'animate-spin': section.status === 'running' }]"+ />+ <span class="text-gray-700">{{ section.label }}</span>+ <span v-if="section.entryCount > 1" class="text-gray-400">+ ({{ section.entryCount }})+ </span>+ <span class="flex-1" />+ <span v-if="section.duration" class="text-gray-500 tabular-nums">+ {{ section.duration }}+ </span>+ </div>+</template>++<script lang="ts" setup>+import { ChevronDownIcon, ChevronRightIcon } from "lucide-vue-next";+import type { Section } from "./types";++defineProps<{+ section: Section;+ isExpanded: boolean;+ indent?: boolean;+}>();++defineEmits<{+ toggle: [];+}>();+</script>diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vueindex 80e5e54d91..e20cd6fe37 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vue+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/TaskRunLogViewer.vue@@ -3,111 +3,111 @@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 -->+ <!-- Multi-deploy view: show deploy groups when server restarts detected -->+ <template v-if="hasMultipleDeploys">+ <!-- Server restart notice --><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)"+ class="flex items-center gap-x-2 px-3 py-2 bg-amber-50 border-b border-amber-200 text-amber-800">- <!-- 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>+ <AlertTriangleIcon class="w-4 h-4 shrink-0" />+ <span>{{ $t("task-run.log-viewer.multiple-deploys-notice") }}</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"+ <!-- Deploy groups -->+ <div+ v-for="(deployGroup, deployIdx) in deployGroups"+ :key="deployGroup.deployId"+ class="border-b border-gray-300 last:border-b-0">- <template #default="{ item, index }">+ <!-- Deploy Header -->+ <div+ class="flex items-center gap-x-2 px-3 py-1.5 bg-gray-100 hover:bg-gray-200 cursor-pointer select-none"+ @click="toggleDeploy(deployGroup.deployId)"+ >+ <component+ :is="isDeployExpanded(deployGroup.deployId) ? ChevronDownIcon : ChevronRightIcon"+ class="w-3.5 h-3.5 text-gray-500 shrink-0"+ />+ <ServerIcon class="w-3.5 h-3.5 text-gray-500 shrink-0" />+ <span class="text-gray-700 font-medium">+ {{ $t("task-run.log-viewer.deployment-n", { n: deployIdx + 1 }) }}+ </span>+ <span class="text-gray-400 text-[10px] font-normal">+ {{ deployGroup.deployId.substring(0, 8) }}+ </span>+ </div>++ <!-- Sections within deploy group -->+ <div v-if="isDeployExpanded(deployGroup.deployId)"><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 }"+ v-for="section in deployGroup.sections"+ :key="section.id"+ class="border-b border-gray-200 last:border-b-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>+ <SectionHeader+ :section="section"+ :is-expanded="isSectionExpanded(section.id)"+ :indent="true"+ @toggle="toggleSection(section.id)"+ />+ <SectionContent+ v-if="isSectionExpanded(section.id)"+ :section="section"+ :indent="true"+ /></div>- </template>- </NVirtualList>- </div>+ </div>+ </div>+ </template>++ <!-- Single-deploy view: standard flat sections -->+ <template v-else>+ <div+ v-for="section in sections"+ :key="section.id"+ class="border-b border-gray-200 last:border-b-0"+ >+ <SectionHeader+ :section="section"+ :is-expanded="isSectionExpanded(section.id)"+ @toggle="toggleSection(section.id)"+ />+ <SectionContent+ v-if="isSectionExpanded(section.id)"+ :section="section"+ />+ </div>+ </template></div></template><script lang="ts" setup>-import { ChevronDownIcon, ChevronRightIcon } from "lucide-vue-next";-import { NVirtualList } from "naive-ui";+import {+ AlertTriangleIcon,+ ChevronDownIcon,+ ChevronRightIcon,+ ServerIcon,+} from "lucide-vue-next";import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";+import SectionContent from "./SectionContent.vue";+import SectionHeader from "./SectionHeader.vue";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(+const {+ sections,+ hasMultipleDeploys,+ deployGroups,+ toggleSection,+ toggleDeploy,+ isSectionExpanded,+ isDeployExpanded,+} = useTaskRunLogSections(() => props.entries,() => props.sheet);diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.tsindex 21932fc461..85afee96ca 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/types.ts@@ -30,3 +30,8 @@ export interface EntryGroup {type: TaskRunLogEntry_Type;entries: import("@/types/proto-es/v1/rollout_service_pb").TaskRunLogEntry[];}++export interface DeployGroup {+ deployId: string;+ sections: Section[];+}diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.tsindex b827386aaf..8749b64f4a 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/useTaskRunLogSections.ts@@ -16,12 +16,14 @@ import {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 type { DeployGroup, DisplayItem, Section, SectionStatus } from "./types";import {formatDuration,formatRelativeTime,formatTime,getTimestampMs,+ getUniqueDeployIds,+ groupEntriesByDeploy,groupEntriesByType,hasError,isComplete,@@ -37,9 +39,14 @@ const STATUS_CONFIG: Record<SectionStatus, { icon: Component; class: string }> =export interface UseTaskRunLogSectionsReturn {sections: ComputedRef<Section[]>;+ hasMultipleDeploys: ComputedRef<boolean>;+ deployGroups: ComputedRef<DeployGroup[]>;expandedSections: Ref<Set<string>>;+ expandedDeploys: Ref<Set<string>>;toggleSection: (sectionId: string) => void;+ toggleDeploy: (deployId: string) => void;isSectionExpanded: (sectionId: string) => boolean;+ isDeployExpanded: (deployId: string) => boolean;}export const useTaskRunLogSections = (@@ -50,6 +57,8 @@ export const useTaskRunLogSections = (const expandedSections = ref<Set<string>>(new Set());const userCollapsedSections = ref<Set<string>>(new Set());+ const expandedDeploys = ref<Set<string>>(new Set());+ const userCollapsedDeploys = ref<Set<string>>(new Set());const getSectionLabel = (type: TaskRunLogEntry_Type): string => {const labelMap: Partial<Record<TaskRunLogEntry_Type, string>> = {@@ -207,16 +216,23 @@ export const useTaskRunLogSections = (return "running";};- const sections = computed((): Section[] => {- const entriesValue = toValue(entries);- if (!entriesValue.length) return [];+ const buildSectionsFromEntries = (+ entriesList: TaskRunLogEntry[],+ idPrefix = "",+ forceError = false+ ): Section[] => {+ if (!entriesList.length) return [];- const groups = groupEntriesByType(entriesValue);+ const groups = groupEntriesByType(entriesList);return groups.map((group, groupIdx) => {const { type, entries: groupEntries } = group;- const status = calculateSectionStatus(groupEntries);+ // For interrupted deployments, treat "running" as "error"+ let status = calculateSectionStatus(groupEntries);+ if (forceError && status === "running") {+ status = "error";+ }const timestamps = groupEntries.map((e) => getTimestampMs(e.logTime))@@ -229,7 +245,9 @@ export const useTaskRunLogSections = (const statusCfg = STATUS_CONFIG[status];return {- id: `section-${groupIdx}`,+ id: idPrefix+ ? `${idPrefix}-section-${groupIdx}`+ : `section-${groupIdx}`,type,label: getSectionLabel(type),status,@@ -240,6 +258,40 @@ export const useTaskRunLogSections = (items,};});+ };++ const sections = computed((): Section[] => {+ const entriesValue = toValue(entries);+ return buildSectionsFromEntries(entriesValue);+ });++ const hasMultipleDeploys = computed((): boolean => {+ const entriesValue = toValue(entries);+ const deployIds = getUniqueDeployIds(entriesValue);+ return deployIds.length > 1;+ });++ const deployGroups = computed((): DeployGroup[] => {+ const entriesValue = toValue(entries);+ if (!entriesValue.length) return [];++ const deployIds = getUniqueDeployIds(entriesValue);+ if (deployIds.length <= 1) return [];++ const entriesByDeploy = groupEntriesByDeploy(entriesValue);++ return deployIds.map((deployId, idx) => {+ const deployEntries = entriesByDeploy.get(deployId) || [];+ const isLatestDeploy = idx === deployIds.length - 1;+ return {+ deployId,+ sections: buildSectionsFromEntries(+ deployEntries,+ deployId,+ !isLatestDeploy // forceError: true for non-latest deploys+ ),+ };+ });});const toggleSection = (sectionId: string) => {@@ -252,10 +304,24 @@ export const useTaskRunLogSections = (}};+ const toggleDeploy = (deployId: string) => {+ if (expandedDeploys.value.has(deployId)) {+ deleteFromSet(expandedDeploys, deployId);+ addToSet(userCollapsedDeploys, deployId);+ } else {+ addToSet(expandedDeploys, deployId);+ deleteFromSet(userCollapsedDeploys, deployId);+ }+ };+const isSectionExpanded = (sectionId: string): boolean => {return expandedSections.value.has(sectionId);};+ const isDeployExpanded = (deployId: string): boolean => {+ return expandedDeploys.value.has(deployId);+ };+// Auto-expand error sections (respecting user's manual collapse)watch(sections,@@ -272,10 +338,38 @@ export const useTaskRunLogSections = ({ immediate: true });+ // Auto-expand all deploys and error sections in deploy groups+ watch(+ deployGroups,+ (newDeployGroups) => {+ for (const deployGroup of newDeployGroups) {+ // Auto-expand all deploy groups by default+ if (!userCollapsedDeploys.value.has(deployGroup.deployId)) {+ addToSet(expandedDeploys, deployGroup.deployId);+ }+ // Auto-expand error sections within deploy groups+ for (const section of deployGroup.sections) {+ if (+ section.status === "error" &&+ !userCollapsedSections.value.has(section.id)+ ) {+ addToSet(expandedSections, section.id);+ }+ }+ }+ },+ { immediate: true }+ );+return {sections,+ hasMultipleDeploys,+ deployGroups,expandedSections,+ expandedDeploys,toggleSection,+ toggleDeploy,isSectionExpanded,+ isDeployExpanded,};};diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.ts b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.tsindex c889f2fdff..c641420abc 100644--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.ts+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer/utils.ts@@ -104,3 +104,42 @@ export const groupEntriesByType = (return groups;};++// Get unique deploy IDs from entries, preserving order of first appearance+export const getUniqueDeployIds = (entries: TaskRunLogEntry[]): string[] => {+ if (!entries.length) return [];++ const sortedEntries = [...entries].sort((a, b) => {+ return getTimestampMs(a.logTime) - getTimestampMs(b.logTime);+ });++ const seen = new Set<string>();+ const deployIds: string[] = [];++ for (const entry of sortedEntries) {+ const deployId = entry.deployId || "";+ if (deployId && !seen.has(deployId)) {+ seen.add(deployId);+ deployIds.push(deployId);+ }+ }++ return deployIds;+};++// Group entries by deploy ID, maintaining time order within each group+export const groupEntriesByDeploy = (+ entries: TaskRunLogEntry[]+): Map<string, TaskRunLogEntry[]> => {+ const result = new Map<string, TaskRunLogEntry[]>();++ for (const entry of entries) {+ const deployId = entry.deployId || "unknown";+ if (!result.has(deployId)) {+ result.set(deployId, []);+ }+ result.get(deployId)!.push(entry);+ }++ return result;+};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 33f4fd0e8a..c485cdabe4 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -387,6 +387,10 @@"backing-up": "backing up...","retry-attempt": "attempt {current}/{max}","computing": "computing..."+ },+ "log-viewer": {+ "multiple-deploys-notice": "Server restart detected during execution. Logs are grouped by deployment.",+ "deployment-n": "Deployment #{n}"}},"banner": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex bbe85b6263..f38ce076e5 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -387,6 +387,10 @@"backing-up": "haciendo copia de seguridad...","retry-attempt": "intento {current}/{max}","computing": "computación..."+ },+ "log-viewer": {+ "multiple-deploys-notice": "Se detectó un reinicio del servidor durante la ejecución. Los registros están agrupados por despliegue.",+ "deployment-n": "Despliegue #{n}"}},"banner": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 0445318879..15d510e404 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -387,6 +387,10 @@"backing-up": "バックアップ中...","retry-attempt": "試行 {current}/{max}","computing": "コンピューティング..."+ },+ "log-viewer": {+ "multiple-deploys-notice": "実行中にサーバーの再起動が検出されました。ログはデプロイごとにグループ化されています。",+ "deployment-n": "デプロイ #{n}"}},"banner": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 45e45e49de..f1de15da8a 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -387,6 +387,10 @@"backing-up": "đang sao lưu...","retry-attempt": "nỗ lực {current}/{max}","computing": "tính toán..."+ },+ "log-viewer": {+ "multiple-deploys-notice": "Phát hiện khởi động lại máy chủ trong quá trình thực thi. Nhật ký được nhóm theo triển khai.",+ "deployment-n": "Triển khai #{n}"}},"banner": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex bac70500fa..b6bab347e2 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -387,6 +387,10 @@"backing-up": "备份中...","retry-attempt": "第 {current}/{max} 次尝试","computing": "计算中..."+ },+ "log-viewer": {+ "multiple-deploys-notice": "检测到执行期间服务重启,日志按部署分组显示。",+ "deployment-n": "部署 #{n}"}},"banner": {