Skip to content

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

refactor(frontend): improve task run log table layout and display (#18372)

boojack46bf98d2985e
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue
index 5b2d7f2caf..805460536a 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue
@@ -1,21 +1,18 @@
<template>
- <NEllipsis expand-trigger="click" line-clamp="2" :tooltip="false">
- <AffectedRowsCell v-if="view === 'AFFECTED_ROWS'" v-bind="props" />
- <ErrorCell v-if="view === 'ERROR'" v-bind="props" />
- <StatusUpdateCell v-if="view === 'STATUS_UPDATE'" v-bind="props" />
- <TransactionControlCell
- v-if="view === 'TRANSACTION_CONTROL'"
- v-bind="props"
- />
- <DatabaseSyncCell v-if="view === 'DATABASE_SYNC'" v-bind="props" />
- <PriorBackupCell v-if="view === 'PRIOR_BACKUP'" v-bind="props" />
- <RetryInfoCell v-if="view === 'RETRY_INFO'" v-bind="props" />
- <span v-if="view === 'N/A'">-</span>
- </NEllipsis>
+ <AffectedRowsCell v-if="view === 'AFFECTED_ROWS'" v-bind="props" />
+ <ErrorCell v-else-if="view === 'ERROR'" v-bind="props" />
+ <StatusUpdateCell v-else-if="view === 'STATUS_UPDATE'" v-bind="props" />
+ <TransactionControlCell
+ v-else-if="view === 'TRANSACTION_CONTROL'"
+ v-bind="props"
+ />
+ <DatabaseSyncCell v-else-if="view === 'DATABASE_SYNC'" v-bind="props" />
+ <PriorBackupCell v-else-if="view === 'PRIOR_BACKUP'" v-bind="props" />
+ <RetryInfoCell v-else-if="view === 'RETRY_INFO'" v-bind="props" />
+ <span v-else class="text-control-placeholder">-</span>
</template>
<script setup lang="ts">
-import { NEllipsis } from "naive-ui";
import { computed } from "vue";
import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue
index ec965c1e2b..127263bab2 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue
@@ -85,82 +85,75 @@ const columns = computed((): DataTableColumn<FlattenLogEntry>[] => {
{
key: "batch",
title: () => "#",
- width: 70,
- className: "whitespace-nowrap",
- render: (entry) => {
- return (
- <div class="flex flex-row items-center gap-1">
- <span>
- {String(entry.batch + 1)}
- {entry.serial > 0 ? `.${entry.serial + 1}` : ""}
- </span>
- {lastDeployId.value !== entry.deployId && (
- <NTooltip>
- {{
- trigger: () => (
- <CircleAlertIcon class="w-4 h-auto text-red-600" />
- ),
- default: () => (
- <div class="max-w-[20rem]">
- Deploy ID mismatch. Please check if there is another
- deployment running.
- </div>
- ),
- }}
- </NTooltip>
- )}
- </div>
- );
- },
+ width: 60,
+ minWidth: 60,
+ render: (entry) => (
+ <div class="flex items-center gap-1">
+ <span>
+ {String(entry.batch + 1)}
+ {entry.serial > 0 ? `.${entry.serial + 1}` : ""}
+ </span>
+ {lastDeployId.value !== entry.deployId && (
+ <NTooltip>
+ {{
+ trigger: () => (
+ <CircleAlertIcon class="w-4 h-auto text-red-600" />
+ ),
+ default: () => (
+ <div class="max-w-[20rem]">
+ Deploy ID mismatch. Please check if there is another
+ deployment running.
+ </div>
+ ),
+ }}
+ </NTooltip>
+ )}
+ </div>
+ ),
},
{
key: "type",
title: () => t("common.type"),
- width: 120,
- className: "whitespace-nowrap",
+ width: 140,
+ minWidth: 140,
render: (entry) => {
const text = displayTaskRunLogEntryType(entry.type);
- if (text) {
- return <span class="text-sm">{text}</span>;
- }
- return <span class="text-sm text-control-placeholder">-</span>;
+ return text ? (
+ <span class="whitespace-nowrap">{text}</span>
+ ) : (
+ <span class="text-control-placeholder">-</span>
+ );
},
},
{
key: "detail",
title: () => t("common.detail"),
- width: "40%",
- render: (entry) => {
- return (
- <div class="flex flex-row justify-start items-center">
- <DetailCell entry={entry} sheet={props.sheet} />
- </div>
- );
- },
+ minWidth: 120,
+ resizable: true,
+ ellipsis: true,
+ render: (entry) => <DetailCell entry={entry} sheet={props.sheet} />,
},
{
key: "statement",
title: () => t("common.statement"),
- width: "60%",
- render: (entry) => {
- return <StatementCell entry={entry} sheet={props.sheet} />;
- },
+ minWidth: 150,
+ resizable: true,
+ ellipsis: true,
+ render: (entry) => <StatementCell entry={entry} sheet={props.sheet} />,
},
{
key: "duration",
title: () => t("common.duration"),
- width: 120,
- render: (entry) => {
- return <DurationCell entry={entry} />;
- },
+ width: 100,
+ minWidth: 80,
+ render: (entry) => <DurationCell entry={entry} />,
},
{
key: "log-time",
title: () => t("common.time"),
- width: 120,
- render: (entry) => {
- return <LogTimeCell entry={entry} />;
- },
+ width: 100,
+ minWidth: 80,
+ render: (entry) => <LogTimeCell entry={entry} />,
},
];
});
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
index a7e83d0acc..3c57c0e628 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
+++ b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
@@ -49,12 +49,26 @@
</div>
<!-- Line 2: Task run logs -->
- <TaskRunLogEntries
- v-if="summary.latestEntries.length > 0"
- :entries="summary.latestEntries"
- :sheet="sheet"
- class="pt-1"
- />
+ <div v-if="summary.latestEntries.length > 0">
+ <TaskRunLogEntries
+ :entries="summary.latestEntries"
+ :sheet="sheet"
+ :is-truncated="summary.isTruncated"
+ />
+ <div
+ v-if="summary.isTruncated"
+ class="flex items-center justify-between px-3 py-1.5 text-xs text-gray-500 bg-gray-50 border border-gray-200 border-t-0 rounded-b"
+ >
+ <span>{{
+ t("task-run.showing-recent-logs", { count: MAX_DISPLAY_ENTRIES })
+ }}</span>
+ <RouterLink v-if="taskName" :to="`/${taskName}`">
+ <NButton text size="tiny" type="info">
+ {{ t("task-run.view-full-logs") }}
+ </NButton>
+ </RouterLink>
+ </div>
+ </div>
</div>
</template>
@@ -69,14 +83,18 @@ import {
UserIcon,
XCircleIcon,
} from "lucide-vue-next";
-import { NTooltip } from "naive-ui";
+import { NButton, NTooltip } from "naive-ui";
import type { Component, FunctionalComponent } from "vue";
import { computed, h } from "vue";
import { useI18n } from "vue-i18n";
+import { RouterLink } from "vue-router";
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 {
+ MAX_DISPLAY_ENTRIES,
+ type TaskRunLogSummary,
+} from "./composables/useTaskRunLogSummary";
import TaskRunLogEntries from "./TaskRunLogEntries.vue";
// Types
@@ -151,7 +169,7 @@ const STATUS_CONFIG: Record<Task_Status, StatusConfig> = {
},
};
-// Props - simplified to only required fields
+// Props
const props = defineProps<{
status: Task_Status;
updateTime?: TimestampType;
@@ -160,6 +178,7 @@ const props = defineProps<{
duration?: string;
affectedRowsDisplay?: string;
summary: TaskRunLogSummary;
+ taskName?: string;
}>();
const { t } = useI18n();
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue
index 49f14892dc..6cc910383d 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue
+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskItem.vue
@@ -197,6 +197,7 @@
:duration="timingType !== 'scheduled' ? timingDisplay : undefined"
:affected-rows-display="affectedRowsDisplay"
:summary="taskRunLogSummary"
+ :task-name="task.name"
/>
</div>
</div>
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue
index 471f40c93b..a9602822af 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue
+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue
@@ -1,14 +1,18 @@
<template>
<NVirtualList
v-if="displayItems.length > 0"
+ ref="virtualListRef"
:items="displayItems"
:item-size="20"
item-resizable
item-key="key"
- class="w-full font-mono text-xs bg-gray-50 border border-gray-200 rounded p-2 max-h-48"
+ class="w-full font-mono text-xs bg-gray-50 border border-gray-200 p-2 max-h-48"
+ :class="isTruncated ? 'rounded-t rounded-b-none' : 'rounded'"
+ @scroll="handleScroll"
>
<template #default="{ item }">
- <div class="flex items-start gap-x-2 py-0.5">
+ <div v-if="item.isSpacer" class="h-3" />
+ <div v-else class="flex items-start gap-x-2 py-0.5">
<span class="text-gray-400 shrink-0">{{ item.time }}</span>
<span class="shrink-0" :class="item.levelClass"
>[{{ item.level }}]</span
@@ -22,8 +26,9 @@
<script lang="ts" setup>
import type { Timestamp as PbTimestamp } from "@bufbuild/protobuf/wkt";
+import type { VirtualListInst } from "naive-ui";
import { NVirtualList } from "naive-ui";
-import { computed } from "vue";
+import { computed, nextTick, onMounted, ref, watch } from "vue";
import { getDateForPbTimestampProtoEs } from "@/types";
import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";
import {
@@ -45,6 +50,7 @@ interface DisplayItem {
typeLabel: string;
detail: string;
detailClass: string;
+ isSpacer?: boolean;
}
// Constants
@@ -76,12 +82,52 @@ const TXN_TYPE_LABELS: Partial<
[TaskRunLogEntry_TransactionControl_Type.ROLLBACK]: "ROLLBACK",
};
+// Auto-scroll threshold (px) for detecting if user is at bottom
+const SCROLL_THRESHOLD = 50;
+
+// Spacer item to ensure last log entry is fully visible when scrolled to bottom
+const SPACER_ITEM: DisplayItem = {
+ key: "spacer",
+ time: "",
+ level: "INF",
+ levelClass: "",
+ typeLabel: "",
+ detail: "",
+ detailClass: "",
+ isSpacer: true,
+};
+
// Props
const props = defineProps<{
entries: TaskRunLogEntry[];
sheet?: Sheet;
+ isTruncated?: boolean;
}>();
+// Refs for auto-scroll
+const virtualListRef = ref<VirtualListInst>();
+const isUserAtBottom = ref(true);
+
+// Compare two protobuf timestamps for sorting (ascending)
+const compareTimestamps = (
+ a: PbTimestamp | undefined,
+ b: PbTimestamp | undefined
+): number => {
+ if (!a && !b) return 0;
+ if (!a) return -1;
+ if (!b) return 1;
+ const secondsDiff = Number(a.seconds) - Number(b.seconds);
+ if (secondsDiff !== 0) return secondsDiff;
+ return a.nanos - b.nanos;
+};
+
+// Sort entries by logTime ascending (oldest first)
+const sortedEntries = computed(() => {
+ return [...props.entries].sort((a, b) =>
+ compareTimestamps(a.logTime, b.logTime)
+ );
+});
+
// Log display utilities
const formatLogTime = (timestamp: PbTimestamp | undefined): string => {
if (!timestamp) return "--:--:--.---";
@@ -249,7 +295,7 @@ const getEntryKey = (entry: TaskRunLogEntry, index: number): string => {
// Pre-compute display data to avoid multiple function calls per render
const displayItems = computed((): DisplayItem[] => {
- return props.entries.map((entry, index) => {
+ const items: DisplayItem[] = sortedEntries.value.map((entry, index) => {
const level = getLogLevel(entry);
const config = LOG_LEVEL_CONFIG[level];
return {
@@ -262,5 +308,37 @@ const displayItems = computed((): DisplayItem[] => {
detailClass: config.detailClass,
};
});
+ if (items.length > 0) {
+ items.push(SPACER_ITEM);
+ }
+ return items;
});
+
+// Scroll to bottom helper
+const scrollToBottom = () => {
+ nextTick(() => {
+ virtualListRef.value?.scrollTo({ position: "bottom" });
+ });
+};
+
+// Auto-scroll: detect if user is at bottom
+const handleScroll = (event: Event) => {
+ const el = event.target as HTMLElement;
+ const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
+ isUserAtBottom.value = distanceFromBottom < SCROLL_THRESHOLD;
+};
+
+// Scroll to bottom on initial mount
+onMounted(scrollToBottom);
+
+// Auto-scroll to bottom when new entries arrive (if user is at bottom)
+watch(
+ () => props.entries.length,
+ () => {
+ if (isUserAtBottom.value) {
+ scrollToBottom();
+ }
+ }
+);
</script>
+
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
index 7e22e3d8a9..8aa9d4a12a 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
@@ -13,10 +13,12 @@ export interface TaskRunLogSummary {
totalAffectedRows: bigint;
hasAffectedRows: boolean;
latestEntries: TaskRunLogEntry[];
+ totalEntryCount: number;
+ isTruncated: boolean;
}
// Limit entries to prevent performance issues with large logs
-const MAX_DISPLAY_ENTRIES = 100;
+export const MAX_DISPLAY_ENTRIES = 100;
export interface UseTaskRunLogSummaryReturn {
taskRunLog: ComputedRef<TaskRunLog | undefined>;
@@ -92,11 +94,17 @@ export const useTaskRunLogSummary = (
totalAffectedRows: BigInt(0),
hasAffectedRows: false,
latestEntries: [],
+ totalEntryCount: 0,
+ isTruncated: false,
};
if (!log?.entries?.length) return result;
- for (const entry of log.entries) {
+ const entries = log.entries;
+ result.totalEntryCount = entries.length;
+ result.isTruncated = entries.length > MAX_DISPLAY_ENTRIES;
+
+ for (const entry of entries) {
if (entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {
const affectedRows = entry.commandExecute?.response?.affectedRows;
if (affectedRows !== undefined) {
@@ -106,11 +114,9 @@ export const useTaskRunLogSummary = (
}
}
- // Get latest entries (reversed, limited for performance)
- // Slice from the end to get latest entries, then reverse for display order
- const entries = log.entries;
+ // Get latest entries (limited for performance)
const startIndex = Math.max(0, entries.length - MAX_DISPLAY_ENTRIES);
- result.latestEntries = entries.slice(startIndex).reverse();
+ result.latestEntries = entries.slice(startIndex);
return result;
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f510fd1392..d34707c9a8 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -357,6 +357,8 @@
"history": "Execution History",
"latest-logs": "Latest Logs",
"latest": "Latest Execution",
+ "showing-recent-logs": "Showing recent {count} logs",
+ "view-full-logs": "View full logs",
"status": {
"enqueued": "Waiting for execution.",
"enqueued-with-rollout-time": "Waiting to execute after {time}.",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 20178cc58e..69155072fd 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -357,6 +357,8 @@
"history": "Historial de ejecución de tareas",
"latest-logs": "Últimos registros",
"latest": "Última ejecución",
+ "showing-recent-logs": "Mostrando registros recientes de {count}",
+ "view-full-logs": "Ver registros completos",
"status": {
"enqueued": "Esperando a ser ejecutada.",
"enqueued-with-rollout-time": "Esperando para ejecutar, {time} para ejecutar.",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 147c870953..f958873d96 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -357,6 +357,8 @@
"history": "タスク実行履歴",
"latest-logs": "最新のログ",
"latest": "最新の実行",
+ "showing-recent-logs": "最近の{count}ログを表示しています",
+ "view-full-logs": "完全なログを表示",
"status": {
"enqueued": "処刑を待っています。",
"enqueued-with-rollout-time": "実行を待機しています。{time} の後に実行されます。",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 939915bd3e..3ef24cb0b8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -357,6 +357,8 @@
"history": "Lịch sử thực hiện nhiệm vụ",
"latest-logs": "Nhật ký mới nhất",
"latest": "Thực hiện mới nhất",
+ "showing-recent-logs": "Hiển thị nhật ký {count} gần đây",
+ "view-full-logs": "Xem nhật ký đầy đủ",
"status": {
"enqueued": "Đang chờ thực thi.",
"enqueued-with-rollout-time": "Đang chờ thực thi sau {time}.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 54907b3766..7fc1269f58 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -357,6 +357,8 @@
"history": "执行记录",
"latest-logs": "执行日志",
"latest": "最新执行",
+ "showing-recent-logs": "显示最近 {count} 条日志",
+ "view-full-logs": "查看完整日志",
"status": {
"enqueued": "等待执行。",
"enqueued-with-rollout-time": "等待执行,{time}后执行。",