Skip to content

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

refactor(frontend): consolidate task run log display with collapsible sections (#18383)

boojack9269ee8d1291
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
index 9eca357d83..c81577a9a4 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
@@ -50,8 +50,8 @@ import {
flattenTaskV1List,
} from "@/utils";
import { extractChangelogUID } from "@/utils/v1/changelog";
+import { displayTaskRunLogEntryType } from "@/utils/v1/taskRunLog";
import { useIssueContext } from "../../logic";
-import { displayTaskRunLogEntryType } from "./TaskRunLogTable/common";
export type CommentLink = {
title: string;
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
index 167545fee9..bc7d432708 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue
@@ -1,7 +1,15 @@
<template>
<NTabs v-model:value="state.currentTab" type="line">
<NTabPane name="LOG" :tab="$t('issue.task-run.logs')">
- <TaskRunLogTable :key="componentId" :task-run="taskRun" :sheet="sheet" />
+ <TaskRunLogViewer
+ v-if="logEntries.length > 0"
+ :key="componentId"
+ :entries="logEntries"
+ :sheet="sheet"
+ />
+ <div v-else-if="isFetching" class="py-4 text-gray-500 text-sm">
+ {{ $t("common.loading") }}
+ </div>
</NTabPane>
<NTabPane
v-if="showTaskRunSessionTab"
@@ -12,7 +20,7 @@
</NTabPane>
<template v-if="showRefreshButton" #suffix>
- <NButton text @click="componentId = uniqueId()">
+ <NButton text @click="refresh">
<template #icon>
<RefreshCcwIcon class="w-4 h-auto" />
</template>
@@ -23,18 +31,22 @@
</template>
<script lang="ts" setup>
+import { create } from "@bufbuild/protobuf";
+import { computedAsync } from "@vueuse/core";
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 { rolloutServiceClientConnect } from "@/grpcweb";
import { useSheetV1Store } from "@/store";
import { Engine } from "@/types/proto-es/v1/common_pb";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
import {
+ GetTaskRunLogRequestSchema,
type TaskRun,
TaskRun_Status,
} from "@/types/proto-es/v1/rollout_service_pb";
-import TaskRunLogTable from "./TaskRunLogTable";
import TaskRunSession from "./TaskRunSession";
const TASK_RUN_SESSION_SUPPORTED_ENGINES = [Engine.POSTGRES];
@@ -60,6 +72,26 @@ const sheet = computed(() =>
useSheetV1Store().getSheetByName(props.taskRun.sheet)
);
+// Fetch task run log
+const isFetching = ref(false);
+const taskRunLog = computedAsync(
+ async () => {
+ if (!props.taskRun.name) return undefined;
+ const request = create(GetTaskRunLogRequestSchema, {
+ parent: props.taskRun.name,
+ });
+ return await rolloutServiceClientConnect.getTaskRunLog(request);
+ },
+ undefined,
+ { evaluating: isFetching }
+);
+
+const logEntries = computed(() => taskRunLog.value?.entries ?? []);
+
+const refresh = () => {
+ componentId.value = uniqueId();
+};
+
const showTaskRunSessionTab = computed(
() =>
props.database?.instanceResource &&
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/AffectedRowsCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/AffectedRowsCell.vue
deleted file mode 100644
index 8b1d0fa937..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/AffectedRowsCell.vue
+++ /dev/null
@@ -1,35 +0,0 @@
-<template>
- <span v-if="affectedRows !== undefined && affectedRows !== null">
- {{
- $t("issue.task-run.task-run-log.affected-rows-n", {
- n: Number(affectedRows),
- })
- }}
- </span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const affectedRows = computed(() => {
- const { entry } = props;
- if (entry.type === TaskRunLogEntry_Type.SCHEMA_DUMP && entry.schemaDump) {
- return undefined;
- }
- if (
- entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE &&
- entry.commandExecute
- ) {
- const exec = entry.commandExecute;
- return exec.affectedRows;
- }
- return undefined;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DatabaseSyncCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DatabaseSyncCell.vue
deleted file mode 100644
index b866d542d6..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DatabaseSyncCell.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-<template>
- <span v-if="error" class="text-error">{{ error }}</span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const error = computed(() => {
- const { type, databaseSync } = props.entry;
- if (type === TaskRunLogEntry_Type.DATABASE_SYNC && databaseSync) {
- return databaseSync.error;
- }
- return "";
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue
deleted file mode 100644
index 805460536a..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/DetailCell.vue
+++ /dev/null
@@ -1,85 +0,0 @@
-<template>
- <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 { 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";
-import type { FlattenLogEntry } from "../common";
-import AffectedRowsCell from "./AffectedRowsCell.vue";
-import DatabaseSyncCell from "./DatabaseSyncCell.vue";
-import ErrorCell from "./ErrorCell.vue";
-import PriorBackupCell from "./PriorBackupCell.vue";
-import RetryInfoCell from "./RetryInfoCell.vue";
-import StatusUpdateCell from "./StatusUpdateCell.vue";
-import TransactionControlCell from "./TransactionControlCell.vue";
-
-type View =
- | "N/A"
- | "ERROR"
- | "AFFECTED_ROWS"
- | "STATUS_UPDATE"
- | "TRANSACTION_CONTROL"
- | "DATABASE_SYNC"
- | "PRIOR_BACKUP"
- | "RETRY_INFO";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
- sheet?: Sheet;
-}>();
-
-const view = computed((): View => {
- const {
- type,
- commandExecute,
- taskRunStatusUpdate,
- transactionControl,
- databaseSync,
- priorBackup,
- retryInfo,
- } = props.entry;
- if (type === TaskRunLogEntry_Type.COMMAND_EXECUTE && commandExecute) {
- if (commandExecute.error) {
- return "ERROR";
- }
- if (typeof commandExecute.affectedRows !== "undefined") {
- return "AFFECTED_ROWS";
- }
- return "N/A";
- }
- if (
- type === TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE &&
- taskRunStatusUpdate
- ) {
- return "STATUS_UPDATE";
- }
- if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL && transactionControl) {
- return "TRANSACTION_CONTROL";
- }
- if (type === TaskRunLogEntry_Type.DATABASE_SYNC && databaseSync) {
- return "DATABASE_SYNC";
- }
- if (type === TaskRunLogEntry_Type.PRIOR_BACKUP && priorBackup) {
- if (priorBackup.error) {
- return "ERROR";
- }
- return "PRIOR_BACKUP";
- }
- if (type === TaskRunLogEntry_Type.RETRY_INFO && retryInfo) {
- return "RETRY_INFO";
- }
- return "N/A";
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/ErrorCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/ErrorCell.vue
deleted file mode 100644
index b0b3820d9e..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/ErrorCell.vue
+++ /dev/null
@@ -1,29 +0,0 @@
-<template>
- <span v-if="error" class="text-error">{{ error }}</span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const error = computed(() => {
- const { entry } = props;
- if (
- entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE &&
- entry.commandExecute
- ) {
- const exec = entry.commandExecute;
- return exec.error;
- }
- if (entry.type === TaskRunLogEntry_Type.PRIOR_BACKUP && entry.priorBackup) {
- return entry.priorBackup.error;
- }
- return undefined;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/PriorBackupCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/PriorBackupCell.vue
deleted file mode 100644
index 46813937de..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/PriorBackupCell.vue
+++ /dev/null
@@ -1,47 +0,0 @@
-<template>
- <div v-if="priorBackupDetailItems.length > 0" class="flex">
- <NEllipsis expand-trigger="click" line-clamp="1" :tooltip="false">
- {{ $t("issue.task-run.task-run-log.prior-backup-tables") }}:
- {{
- priorBackupDetailItems
- .map((i) => i.sourceTable)
- .filter(Boolean)
- .map(normalizeTableName)
- .join(", ")
- }}
- </NEllipsis>
- </div>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { NEllipsis } from "naive-ui";
-import { computed } from "vue";
-import type { TaskRun_PriorBackupDetail_Item_Table } from "@/types/proto-es/v1/rollout_service_pb";
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const priorBackupDetailItems = computed(() => {
- const { type, priorBackup } = props.entry;
- if (type === TaskRunLogEntry_Type.PRIOR_BACKUP && priorBackup) {
- return priorBackup.priorBackupDetail?.items || [];
- }
- return [];
-});
-
-const normalizeTableName = (
- table: TaskRun_PriorBackupDetail_Item_Table | undefined
-) => {
- if (!table) {
- return "";
- }
- if (table.schema) {
- return `${table.schema}.${table.table}`;
- }
- return table.table;
-};
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/RetryInfoCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/RetryInfoCell.vue
deleted file mode 100644
index 513f9ea141..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/RetryInfoCell.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-<template>
- <span v-if="!isNaN(retryCount) && !isNaN(maxRetries)">
- {{
- $t("issue.task-run.task-run-log.retry-info", {
- n: retryCount,
- m: maxRetries,
- })
- }}
- </span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const { retryCount, maxRetries } = computed(() => {
- const { type, retryInfo } = props.entry;
- if (type === TaskRunLogEntry_Type.RETRY_INFO && retryInfo) {
- return {
- retryCount: retryInfo.retryCount,
- maxRetries: retryInfo.maximumRetries,
- };
- }
- return { retryCount: Number.NaN, maxRetries: Number.NaN };
-}).value;
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/StatusUpdateCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/StatusUpdateCell.vue
deleted file mode 100644
index 81aae46afa..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/StatusUpdateCell.vue
+++ /dev/null
@@ -1,37 +0,0 @@
-<template>
- <span v-if="status">{{ status }}</span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import {
- TaskRunLogEntry_TaskRunStatusUpdate_Status,
- TaskRunLogEntry_Type,
-} from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const { t } = useI18n();
-
-const status = computed(() => {
- const { type, taskRunStatusUpdate } = props.entry;
- if (
- type === TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE &&
- taskRunStatusUpdate
- ) {
- const { status } = taskRunStatusUpdate;
- if (status === TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_WAITING) {
- return t("issue.task-run.task-run-log.status-update.waiting");
- }
- if (status === TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_RUNNING) {
- return t("issue.task-run.task-run-log.status-update.running");
- }
- }
- return undefined;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/TransactionControlCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/TransactionControlCell.vue
deleted file mode 100644
index 17a59db615..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/TransactionControlCell.vue
+++ /dev/null
@@ -1,52 +0,0 @@
-<template>
- <span v-if="text">{{ text }}</span>
- <span v-else-if="error" class="text-error">{{ error }}</span>
- <span v-else class="text-control-placeholder">-</span>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import {
- TaskRunLogEntry_TransactionControl_Type,
- TaskRunLogEntry_Type,
-} from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const text = computed(() => {
- const { type, transactionControl } = props.entry;
- if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL && transactionControl) {
- if (transactionControl.error) {
- return "";
- }
- if (
- transactionControl.type === TaskRunLogEntry_TransactionControl_Type.BEGIN
- ) {
- return "BEGIN";
- }
- if (
- transactionControl.type === TaskRunLogEntry_TransactionControl_Type.COMMIT
- ) {
- return "COMMIT";
- }
- if (
- transactionControl.type ===
- TaskRunLogEntry_TransactionControl_Type.ROLLBACK
- ) {
- return "ROLLBACK";
- }
- }
- return "";
-});
-
-const error = computed(() => {
- const { type, transactionControl } = props.entry;
- if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL && transactionControl) {
- return transactionControl.error;
- }
- return "";
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/common.ts b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/common.ts
deleted file mode 100644
index 6edc335999..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/common.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import type { FlattenLogEntry } from "../common";
-
-export const detailCellRowSpan = (entry: FlattenLogEntry) => {
- if (
- entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE &&
- entry.commandExecute
- ) {
- const { commandExecute } = entry;
- if (commandExecute.kind === "commandIndexes") {
- if (!commandExecute.done) {
- // Not finished yet, combine several rows
- return commandExecute.commandIndexes.length;
- }
- if (commandExecute.error) {
- // Error, combine several rows
- return commandExecute.commandIndexes.length;
- }
- }
- }
- return 1;
-};
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/index.ts b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/index.ts
deleted file mode 100644
index 856e40b84a..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DetailCell/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import DetailCell from "./DetailCell.vue";
-
-export * from "./common";
-
-export default DetailCell;
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DurationCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DurationCell.vue
deleted file mode 100644
index 3c16412382..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/DurationCell.vue
+++ /dev/null
@@ -1,54 +0,0 @@
-<template>
- <div class="text-sm">
- <NTooltip v-if="duration && entry.startTime && entry.endTime">
- <template #trigger>
- <span class="cursor-default">{{ humanizeDurationV1(duration) }}</span>
- </template>
- <template #default>
- <div>
- <p>
- Start:
- {{ dayjs(entry.startTime).format("YYYY-MM-DD HH:mm:ss.SSS UTCZZ") }}
- </p>
- <p>
- End:
- {{ dayjs(entry.endTime).format("YYYY-MM-DD HH:mm:ss.SSS UTCZZ") }}
- </p>
- </div>
- </template>
- </NTooltip>
- <div v-else class="text-control-placeholder">-</div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import { DurationSchema } from "@bufbuild/protobuf/wkt";
-import { NTooltip } from "naive-ui";
-import { computed } from "vue";
-import { humanizeDurationV1 } from "@/utils";
-import type { FlattenLogEntry } from "./common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const toDuration = (startTime: Date, endTime: Date) => {
- const ms = endTime.getTime() - startTime.getTime();
- const seconds = Math.floor(ms / 1000);
- const nanos = (ms % 1000) * 1e6;
- return create(DurationSchema, {
- seconds: BigInt(seconds),
- nanos,
- });
-};
-
-const duration = computed(() => {
- const { entry } = props;
- const { startTime, endTime } = entry;
- if (startTime && endTime) {
- return toDuration(startTime, endTime);
- }
- return undefined;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/LogTimeCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/LogTimeCell.vue
deleted file mode 100644
index e40cdfe3a7..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/LogTimeCell.vue
+++ /dev/null
@@ -1,24 +0,0 @@
-<template>
- <div class="text-sm">
- <HumanizeDate
- v-if="logTime"
- :date="logTime"
- format="YYYY-MM-DD HH:mm:ss.SSS UTCZZ"
- />
- <div v-else class="text-control-placeholder">-</div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import HumanizeDate from "@/components/misc/HumanizeDate.vue";
-import type { FlattenLogEntry } from "./common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
-}>();
-
-const logTime = computed(() => {
- return props.entry.startTime;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue
deleted file mode 100644
index 567b71f89d..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue
+++ /dev/null
@@ -1,69 +0,0 @@
-<template>
- <div class="text-sm group">
- <TextOverflowPopover
- v-if="statement"
- :content="statement.trim()"
- :max-length="100"
- :max-popover-content-length="1000"
- :line-wrap="false"
- :line-break-replacer="' '"
- code-class="relative"
- placement="top"
- >
- <template #default="{ displayContent }">
- <span class="flex-1 flex flex-row justify-start items-center gap-x-1">
- <span class="line-clamp-1">
- {{ displayContent }}
- </span>
- <CopyButton :content="statement.trim()" />
- </span>
- </template>
- <template #popover-header>
- <div class="absolute bottom-1 right-1">
- <CopyButton :content="statement.trim()" />
- </div>
- </template>
- </TextOverflowPopover>
- <div v-else class="text-control-placeholder">-</div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import TextOverflowPopover from "@/components/misc/TextOverflowPopover.vue";
-import { CopyButton } from "@/components/v2";
-import { 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 type { FlattenLogEntry } from "./common";
-
-const props = defineProps<{
- entry: FlattenLogEntry;
- sheet?: Sheet;
-}>();
-
-const statement = computed(() => {
- const { entry, sheet } = props;
- if (entry.type === TaskRunLogEntry_Type.SCHEMA_DUMP && entry.schemaDump) {
- return "";
- }
- if (
- entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE &&
- entry.commandExecute
- ) {
- if (entry.commandExecute.kind === "statement") {
- return entry.commandExecute.statement;
- }
- if (!sheet) {
- return "";
- }
- if (!sheet.payload?.commands) {
- return "";
- }
-
- const { commandExecute } = entry;
- return extractSheetCommandByIndex(sheet, commandExecute.commandIndex) ?? "";
- }
- return "";
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue
deleted file mode 100644
index 127263bab2..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue
+++ /dev/null
@@ -1,160 +0,0 @@
-<template>
- <NDataTable
- :columns="columns"
- :loading="isLoading"
- :data="flattenLogEntries"
- :row-key="rowKey"
- max-height="60vh"
- virtual-scroll
- size="small"
- />
-</template>
-
-<script setup lang="tsx">
-import { create } from "@bufbuild/protobuf";
-import { computedAsync } from "@vueuse/core";
-import { last } from "lodash-es";
-import { CircleAlertIcon } from "lucide-vue-next";
-import { type DataTableColumn, NDataTable, NTooltip } from "naive-ui";
-import { computed, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { rolloutServiceClientConnect } from "@/grpcweb";
-import {
- GetTaskRunLogRequestSchema,
- type TaskRun,
-} from "@/types/proto-es/v1/rollout_service_pb";
-import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
-import {
- convertTaskRunLogEntryToFlattenLogEntries,
- displayTaskRunLogEntryType,
- type FlattenLogEntry,
-} from "./common";
-import DetailCell from "./DetailCell";
-import DurationCell from "./DurationCell.vue";
-import LogTimeCell from "./LogTimeCell.vue";
-import StatementCell from "./StatementCell.vue";
-
-const props = defineProps<{
- taskRun: TaskRun;
- sheet?: Sheet;
-}>();
-
-const { t } = useI18n();
-const isFetching = ref(false);
-
-const taskRunLog = computedAsync(
- async () => {
- const request = create(GetTaskRunLogRequestSchema, {
- parent: props.taskRun.name,
- });
- const response = await rolloutServiceClientConnect.getTaskRunLog(request);
- return response;
- },
- undefined,
- {
- evaluating: isFetching,
- }
-);
-
-// Only show loading on initial load, not on refresh
-const isLoading = computed(
- () => isFetching.value && !taskRunLog.value?.entries?.length
-);
-
-const logEntries = computed(() => {
- if (!props.sheet) return [];
- return taskRunLog.value?.entries ?? [];
-});
-const flattenLogEntries = computed(() => {
- const flattenEntries: FlattenLogEntry[] = [];
- logEntries.value.forEach((entry, batch) => {
- flattenEntries.push(
- ...convertTaskRunLogEntryToFlattenLogEntries(entry, batch)
- );
- });
- return flattenEntries;
-});
-const lastDeployId = computed(() => last(logEntries.value)?.deployId);
-
-const rowKey = (entry: FlattenLogEntry) => {
- return `${entry.batch}-${entry.serial}`;
-};
-
-const columns = computed((): DataTableColumn<FlattenLogEntry>[] => {
- return [
- {
- key: "batch",
- title: () => "#",
- 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: 140,
- minWidth: 140,
- render: (entry) => {
- const text = displayTaskRunLogEntryType(entry.type);
- return text ? (
- <span class="whitespace-nowrap">{text}</span>
- ) : (
- <span class="text-control-placeholder">-</span>
- );
- },
- },
- {
- key: "detail",
- title: () => t("common.detail"),
- minWidth: 120,
- resizable: true,
- ellipsis: true,
- render: (entry) => <DetailCell entry={entry} sheet={props.sheet} />,
- },
- {
- key: "statement",
- title: () => t("common.statement"),
- minWidth: 150,
- resizable: true,
- ellipsis: true,
- render: (entry) => <StatementCell entry={entry} sheet={props.sheet} />,
- },
- {
- key: "duration",
- title: () => t("common.duration"),
- width: 100,
- minWidth: 80,
- render: (entry) => <DurationCell entry={entry} />,
- },
- {
- key: "log-time",
- title: () => t("common.time"),
- width: 100,
- minWidth: 80,
- render: (entry) => <LogTimeCell entry={entry} />,
- },
- ];
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/common.ts b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/common.ts
deleted file mode 100644
index 10e85771e3..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/common.ts
+++ /dev/null
@@ -1,224 +0,0 @@
-import { t } from "@/plugins/i18n";
-import { getDateForPbTimestampProtoEs } from "@/types";
-import {
- type TaskRunLogEntry,
- type TaskRunLogEntry_ComputeDiff,
- type TaskRunLogEntry_DatabaseSync,
- type TaskRunLogEntry_PriorBackup,
- type TaskRunLogEntry_RetryInfo,
- type TaskRunLogEntry_SchemaDump,
- type TaskRunLogEntry_TaskRunStatusUpdate,
- type TaskRunLogEntry_TransactionControl,
- TaskRunLogEntry_Type,
-} from "@/types/proto-es/v1/rollout_service_pb";
-
-export type FlattenLogEntry = {
- batch: number;
- serial: number;
- type: TaskRunLogEntry_Type;
- deployId: string;
- startTime?: Date;
- endTime?: Date;
- schemaDump?: TaskRunLogEntry_SchemaDump;
- commandExecute?:
- | {
- kind: "commandIndexes";
- commandIndex: number;
- commandIndexes: number[];
- done: boolean;
- affectedRows?: bigint;
- error?: string;
- }
- | {
- kind: "statement";
- statement: string;
- done: boolean;
- affectedRows?: bigint;
- error?: string;
- };
- taskRunStatusUpdate?: TaskRunLogEntry_TaskRunStatusUpdate;
- transactionControl?: TaskRunLogEntry_TransactionControl;
- databaseSync?: TaskRunLogEntry_DatabaseSync;
- priorBackup?: TaskRunLogEntry_PriorBackup;
- retryInfo?: TaskRunLogEntry_RetryInfo;
- computeDiff?: TaskRunLogEntry_ComputeDiff;
-};
-
-export const displayTaskRunLogEntryType = (type: TaskRunLogEntry_Type) => {
- if (type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {
- return t("issue.task-run.task-run-log.entry-type.command-execute");
- }
- if (type === TaskRunLogEntry_Type.SCHEMA_DUMP) {
- return t("issue.task-run.task-run-log.entry-type.schema-dump");
- }
- if (type === TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE) {
- return t("issue.task-run.task-run-log.entry-type.task-run-status-update");
- }
- if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL) {
- return t("issue.task-run.task-run-log.entry-type.transaction-control");
- }
- if (type === TaskRunLogEntry_Type.DATABASE_SYNC) {
- return t("issue.task-run.task-run-log.entry-type.database-sync");
- }
- if (type === TaskRunLogEntry_Type.PRIOR_BACKUP) {
- return t("issue.task-run.task-run-log.entry-type.prior-backup");
- }
- if (type === TaskRunLogEntry_Type.COMPUTE_DIFF) {
- return t("issue.task-run.task-run-log.entry-type.compute-diff");
- }
- if (type === TaskRunLogEntry_Type.RETRY_INFO) {
- return t("issue.task-run.task-run-log.entry-type.retry-info");
- }
-
- console.warn(
- `[displayTaskRunLogEntryType] should never reach this line: type=${TaskRunLogEntry_Type[type]}`
- );
- return "";
-};
-
-export const convertTaskRunLogEntryToFlattenLogEntries = (
- entry: TaskRunLogEntry,
- batch: number
-): FlattenLogEntry[] => {
- const {
- type,
- taskRunStatusUpdate,
- schemaDump,
- commandExecute,
- transactionControl,
- databaseSync,
- deployId,
- priorBackup,
- retryInfo,
- computeDiff,
- } = entry;
- const flattenLogEntries: FlattenLogEntry[] = [];
- if (
- type === TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE &&
- taskRunStatusUpdate
- ) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE,
- startTime: getDateForPbTimestampProtoEs(entry.logTime),
- endTime: undefined,
- taskRunStatusUpdate,
- });
- }
- if (type === TaskRunLogEntry_Type.DATABASE_SYNC && databaseSync) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.DATABASE_SYNC,
- startTime: getDateForPbTimestampProtoEs(databaseSync.startTime),
- endTime: getDateForPbTimestampProtoEs(databaseSync.endTime),
- databaseSync,
- });
- }
- if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL && transactionControl) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.TRANSACTION_CONTROL,
- startTime: getDateForPbTimestampProtoEs(entry.logTime),
- endTime: undefined,
- transactionControl,
- });
- }
- if (type === TaskRunLogEntry_Type.SCHEMA_DUMP && schemaDump) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.SCHEMA_DUMP,
- startTime: getDateForPbTimestampProtoEs(schemaDump.startTime),
- endTime: getDateForPbTimestampProtoEs(schemaDump.endTime),
- schemaDump,
- });
- }
- if (type === TaskRunLogEntry_Type.COMMAND_EXECUTE && commandExecute) {
- const { response, logTime: startTime } = commandExecute;
- if (commandExecute.statement) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.COMMAND_EXECUTE,
- startTime: getDateForPbTimestampProtoEs(startTime),
- endTime: getDateForPbTimestampProtoEs(response?.logTime),
- commandExecute: {
- kind: "statement",
- statement: commandExecute.statement,
- done: !!response,
- affectedRows: response?.affectedRows,
- error: response?.error,
- },
- });
- } else {
- commandExecute.commandIndexes.forEach((commandIndex, serial) => {
- let affectedRows = response?.affectedRows;
- if (
- commandExecute.commandIndexes.length ===
- response?.allAffectedRows.length
- ) {
- affectedRows = response?.allAffectedRows[serial] ?? affectedRows;
- }
- const endTime = response?.logTime;
- flattenLogEntries.push({
- batch,
- deployId,
- serial,
- type: TaskRunLogEntry_Type.COMMAND_EXECUTE,
- startTime: getDateForPbTimestampProtoEs(startTime),
- endTime: getDateForPbTimestampProtoEs(endTime),
- commandExecute: {
- kind: "commandIndexes",
- commandIndex: commandIndex,
- commandIndexes: commandExecute.commandIndexes,
- done: !!response,
- affectedRows: affectedRows,
- error: response?.error,
- },
- });
- });
- }
- }
- if (type === TaskRunLogEntry_Type.PRIOR_BACKUP && priorBackup) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.PRIOR_BACKUP,
- startTime: getDateForPbTimestampProtoEs(priorBackup.startTime),
- endTime: getDateForPbTimestampProtoEs(priorBackup.endTime),
- priorBackup: priorBackup,
- });
- }
- if (type === TaskRunLogEntry_Type.COMPUTE_DIFF && computeDiff) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.COMPUTE_DIFF,
- startTime: getDateForPbTimestampProtoEs(computeDiff.startTime),
- endTime: getDateForPbTimestampProtoEs(computeDiff.endTime),
- computeDiff,
- });
- }
- if (type === TaskRunLogEntry_Type.RETRY_INFO && retryInfo) {
- flattenLogEntries.push({
- batch,
- deployId,
- serial: 0,
- type: TaskRunLogEntry_Type.RETRY_INFO,
- startTime: getDateForPbTimestampProtoEs(entry.logTime),
- endTime: undefined,
- retryInfo,
- });
- }
- return flattenLogEntries;
-};
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/index.ts b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/index.ts
deleted file mode 100644
index e4452795d8..0000000000
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import TaskRunLogTable from "./TaskRunLogTable.vue";
-
-export default TaskRunLogTable;
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
index 8ae41ffdbc..24e60bcf25 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
@@ -24,15 +24,12 @@
<script lang="tsx" setup>
import { create } from "@bufbuild/protobuf";
import { type Duration, DurationSchema } from "@bufbuild/protobuf/wkt";
-import { computedAsync } from "@vueuse/core";
-import { last } from "lodash-es";
import { type DataTableColumn, NButton, NDataTable } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { Drawer, DrawerContent } from "@/components/v2";
-import { useCurrentProjectV1, useSheetV1Store } from "@/store";
-import { useTaskRunLogStore } from "@/store/modules/v1/taskRunLog";
+import { useCurrentProjectV1 } from "@/store";
import {
getDateForPbTimestampProtoEs,
getTimeForPbTimestampProtoEs,
@@ -41,16 +38,10 @@ import {
type TaskRun,
TaskRun_Status,
} from "@/types/proto-es/v1/rollout_service_pb";
-import {
- databaseForTask,
- humanizeDurationV1,
- sheetNameOfTaskV1,
-} from "@/utils";
+import { databaseForTask, humanizeDurationV1 } from "@/utils";
import { useIssueContext } from "../../logic";
import TaskRunComment from "./TaskRunComment.vue";
import TaskRunDetail from "./TaskRunDetail.vue";
-import { convertTaskRunLogEntryToFlattenLogEntries } from "./TaskRunLogTable/common";
-import DetailCell from "./TaskRunLogTable/DetailCell";
import TaskRunStatusIcon from "./TaskRunStatusIcon.vue";
defineOptions({
@@ -63,15 +54,8 @@ defineProps<{
const { t } = useI18n();
const { project } = useCurrentProjectV1();
-const taskRunLogStore = useTaskRunLogStore();
const { selectedTask } = useIssueContext();
-const sheet = computedAsync(async () => {
- return useSheetV1Store().getOrFetchSheetByName(
- sheetNameOfTaskV1(selectedTask.value)
- );
-});
-
const taskRunDetailContext = ref<{
show: boolean;
taskRun?: TaskRun;
@@ -106,24 +90,6 @@ const columnList = computed((): DataTableColumn<TaskRun>[] => {
</div>
),
},
- {
- key: "detail",
- title: () => t("common.detail"),
- width: "20%",
- className: "",
- minWidth: 100,
- resizable: true,
- render: (taskRun) => {
- const entry = getFlattenLogEntry(taskRun);
- return entry ? (
- <div class="flex flex-row justify-start items-center">
- <DetailCell entry={entry} sheet={sheet.value} />
- </div>
- ) : (
- "-"
- );
- },
- },
{
key: "createTime",
title: t("task.created"),
@@ -201,14 +167,4 @@ const showDetail = (taskRun: TaskRun) => {
taskRun,
};
};
-
-const getFlattenLogEntry = (taskRun: TaskRun) => {
- const taskRunLog = taskRunLogStore.getTaskRunLog(taskRun.name);
- const entry = last(taskRunLog.entries);
- if (!entry) {
- return undefined;
- }
- const flattenEntry = convertTaskRunLogEntryToFlattenLogEntries(entry, 0);
- return last(flattenEntry);
-};
</script>
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
index 3c57c0e628..dfc8bdc133 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
+++ b/frontend/src/components/Plan/components/RolloutView/v2/LatestTaskRunInfo.vue
@@ -49,26 +49,11 @@
</div>
<!-- Line 2: Task run logs -->
- <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>
+ <TaskRunLogViewer
+ v-if="summary.entries.length > 0"
+ :entries="summary.entries"
+ :sheet="sheet"
+ />
</div>
</template>
@@ -83,19 +68,15 @@ import {
UserIcon,
XCircleIcon,
} from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
+import { 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 {
- MAX_DISPLAY_ENTRIES,
- type TaskRunLogSummary,
-} from "./composables/useTaskRunLogSummary";
-import TaskRunLogEntries from "./TaskRunLogEntries.vue";
+import type { TaskRunLogSummary } from "./composables/useTaskRunLogSummary";
+import TaskRunLogViewer from "./TaskRunLogViewer.vue";
// Types
interface StatusConfig {
diff --git a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue
deleted file mode 100644
index a9602822af..0000000000
--- a/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogEntries.vue
+++ /dev/null
@@ -1,344 +0,0 @@
-<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 p-2 max-h-48"
- :class="isTruncated ? 'rounded-t rounded-b-none' : 'rounded'"
- @scroll="handleScroll"
- >
- <template #default="{ item }">
- <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
- >
- <span class="text-blue-600 shrink-0">{{ item.typeLabel }}</span>
- <span :class="item.detailClass">{{ item.detail }}</span>
- </div>
- </template>
- </NVirtualList>
-</template>
-
-<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, nextTick, onMounted, ref, watch } from "vue";
-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";
-
-// Types
-type LogLevel = "ERR" | "WRN" | "INF";
-
-interface DisplayItem {
- key: string; // Stable key based on timestamp
- time: string;
- level: LogLevel;
- levelClass: string;
- typeLabel: string;
- detail: string;
- detailClass: string;
- isSpacer?: boolean;
-}
-
-// Constants
-const LOG_LEVEL_CONFIG: Record<
- LogLevel,
- { levelClass: string; detailClass: string }
-> = {
- ERR: { levelClass: "text-red-600", detailClass: "text-red-700" },
- WRN: { levelClass: "text-yellow-600", detailClass: "text-yellow-700" },
- INF: { levelClass: "text-green-600", detailClass: "text-gray-600" },
-};
-
-const ENTRY_TYPE_LABELS: Partial<Record<TaskRunLogEntry_Type, string>> = {
- [TaskRunLogEntry_Type.COMMAND_EXECUTE]: "EXEC",
- [TaskRunLogEntry_Type.SCHEMA_DUMP]: "DUMP",
- [TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE]: "STATUS",
- [TaskRunLogEntry_Type.TRANSACTION_CONTROL]: "TXN",
- [TaskRunLogEntry_Type.DATABASE_SYNC]: "SYNC",
- [TaskRunLogEntry_Type.PRIOR_BACKUP]: "BACKUP",
- [TaskRunLogEntry_Type.COMPUTE_DIFF]: "DIFF",
- [TaskRunLogEntry_Type.RETRY_INFO]: "RETRY",
-};
-
-const TXN_TYPE_LABELS: Partial<
- Record<TaskRunLogEntry_TransactionControl_Type, string>
-> = {
- [TaskRunLogEntry_TransactionControl_Type.BEGIN]: "BEGIN",
- [TaskRunLogEntry_TransactionControl_Type.COMMIT]: "COMMIT",
- [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 "--:--:--.---";
- const date = getDateForPbTimestampProtoEs(timestamp);
- 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 getLogLevel = (entry: TaskRunLogEntry): LogLevel => {
- switch (entry.type) {
- case TaskRunLogEntry_Type.COMMAND_EXECUTE:
- if (entry.commandExecute?.response?.error) return "ERR";
- break;
- case TaskRunLogEntry_Type.TRANSACTION_CONTROL:
- if (entry.transactionControl?.error) return "ERR";
- if (
- entry.transactionControl?.type ===
- TaskRunLogEntry_TransactionControl_Type.ROLLBACK
- ) {
- return "WRN";
- }
- break;
- case TaskRunLogEntry_Type.SCHEMA_DUMP:
- if (entry.schemaDump?.error) return "ERR";
- break;
- case TaskRunLogEntry_Type.DATABASE_SYNC:
- if (entry.databaseSync?.error) return "ERR";
- break;
- case TaskRunLogEntry_Type.PRIOR_BACKUP:
- if (entry.priorBackup?.error) return "ERR";
- break;
- case TaskRunLogEntry_Type.RETRY_INFO:
- return "WRN";
- case TaskRunLogEntry_Type.COMPUTE_DIFF:
- if (entry.computeDiff?.error) return "ERR";
- break;
- }
- return "INF";
-};
-
-const getEntryTypeLabel = (entry: TaskRunLogEntry): string => {
- return ENTRY_TYPE_LABELS[entry.type] ?? "LOG";
-};
-
-// Entry detail handlers
-const truncate = (str: string, maxLen: number): string => {
- return str.length <= maxLen ? str : str.substring(0, maxLen) + "...";
-};
-
-const getCommandExecuteDetail = (entry: TaskRunLogEntry): string => {
- const cmd = entry.commandExecute;
- if (!cmd) return "";
-
- // If error, show error message only
- if (cmd.response?.error) {
- return cmd.response.error;
- }
-
- // Try to get the actual statement
- 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 truncate(stmt, 60);
- }
-
- return "-";
-};
-
-const getTransactionControlDetail = (entry: TaskRunLogEntry): string => {
- const txn = entry.transactionControl;
- if (!txn) return "";
- const typeStr = TXN_TYPE_LABELS[txn.type] ?? "";
- return txn.error ? `${typeStr} error: ${txn.error}` : typeStr;
-};
-
-const getProgressDetail = (
- data: { error?: string; startTime?: unknown; endTime?: unknown } | undefined,
- progressText: string
-): string => {
- if (!data) return "";
- if (data.error) return data.error;
- if (data.startTime && data.endTime) return "completed";
- return progressText;
-};
-
-const getStatusUpdateDetail = (entry: TaskRunLogEntry): string => {
- const status = entry.taskRunStatusUpdate;
- if (!status) return "";
- switch (status.status) {
- case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_WAITING:
- return "waiting to execute";
- case TaskRunLogEntry_TaskRunStatusUpdate_Status.RUNNING_RUNNING:
- return "executing";
- default:
- return "status changed";
- }
-};
-
-const getPriorBackupDetail = (entry: TaskRunLogEntry): string => {
- const backup = entry.priorBackup;
- if (!backup) return "";
- if (backup.error) return backup.error;
- const items = backup.priorBackupDetail?.items;
- if (items?.length) {
- return `completed (${items.length} tables backed up)`;
- }
- if (backup.startTime && backup.endTime) return "completed";
- return "backing up...";
-};
-
-const getRetryInfoDetail = (entry: TaskRunLogEntry): string => {
- const retry = entry.retryInfo;
- if (!retry) return "";
- const attempt = `attempt ${retry.retryCount}/${retry.maximumRetries}`;
- return retry.error ? `${attempt} - ${retry.error}` : attempt;
-};
-
-const getEntryDetail = (entry: TaskRunLogEntry): string => {
- switch (entry.type) {
- case TaskRunLogEntry_Type.COMMAND_EXECUTE:
- return getCommandExecuteDetail(entry);
- case TaskRunLogEntry_Type.TRANSACTION_CONTROL:
- return getTransactionControlDetail(entry);
- case TaskRunLogEntry_Type.SCHEMA_DUMP:
- return getProgressDetail(entry.schemaDump, "dumping...");
- case TaskRunLogEntry_Type.DATABASE_SYNC:
- return getProgressDetail(entry.databaseSync, "syncing...");
- case TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE:
- return getStatusUpdateDetail(entry);
- case TaskRunLogEntry_Type.PRIOR_BACKUP:
- return getPriorBackupDetail(entry);
- case TaskRunLogEntry_Type.RETRY_INFO:
- return getRetryInfoDetail(entry);
- case TaskRunLogEntry_Type.COMPUTE_DIFF:
- return getProgressDetail(entry.computeDiff, "computing...");
- default:
- return "";
- }
-};
-
-// Generate stable key from timestamp
-const getEntryKey = (entry: TaskRunLogEntry, index: number): string => {
- const ts = entry.logTime;
- if (ts) {
- // Use seconds + nanos for uniqueness
- return `${ts.seconds}-${ts.nanos}`;
- }
- // Fallback to index if no timestamp
- return `idx-${index}`;
-};
-
-// Pre-compute display data to avoid multiple function calls per render
-const displayItems = computed((): DisplayItem[] => {
- const items: DisplayItem[] = sortedEntries.value.map((entry, index) => {
- const level = getLogLevel(entry);
- const config = LOG_LEVEL_CONFIG[level];
- return {
- key: getEntryKey(entry, index),
- time: formatLogTime(entry.logTime),
- level,
- levelClass: config.levelClass,
- typeLabel: getEntryTypeLabel(entry),
- detail: getEntryDetail(entry),
- 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/TaskRunLogViewer.vue b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vue
new file mode 100644
index 0000000000..7396b1467b
--- /dev/null
+++ b/frontend/src/components/Plan/components/RolloutView/v2/TaskRunLogViewer.vue
@@ -0,0 +1,477 @@
+<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/composables/useTaskRunLogSummary.ts b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
index 8aa9d4a12a..78be173e0f 100644
--- a/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
+++ b/frontend/src/components/Plan/components/RolloutView/v2/composables/useTaskRunLogSummary.ts
@@ -12,14 +12,9 @@ import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
export interface TaskRunLogSummary {
totalAffectedRows: bigint;
hasAffectedRows: boolean;
- latestEntries: TaskRunLogEntry[];
- totalEntryCount: number;
- isTruncated: boolean;
+ entries: TaskRunLogEntry[];
}
-// Limit entries to prevent performance issues with large logs
-export const MAX_DISPLAY_ENTRIES = 100;
-
export interface UseTaskRunLogSummaryReturn {
taskRunLog: ComputedRef<TaskRunLog | undefined>;
summary: ComputedRef<TaskRunLogSummary>;
@@ -93,18 +88,14 @@ export const useTaskRunLogSummary = (
const result: TaskRunLogSummary = {
totalAffectedRows: BigInt(0),
hasAffectedRows: false,
- latestEntries: [],
- totalEntryCount: 0,
- isTruncated: false,
+ entries: [],
};
if (!log?.entries?.length) return result;
- const entries = log.entries;
- result.totalEntryCount = entries.length;
- result.isTruncated = entries.length > MAX_DISPLAY_ENTRIES;
+ result.entries = log.entries;
- for (const entry of entries) {
+ for (const entry of log.entries) {
if (entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {
const affectedRows = entry.commandExecute?.response?.affectedRows;
if (affectedRows !== undefined) {
@@ -114,9 +105,6 @@ export const useTaskRunLogSummary = (
}
}
- // Get latest entries (limited for performance)
- const startIndex = Math.max(0, entries.length - MAX_DISPLAY_ENTRIES);
- result.latestEntries = entries.slice(startIndex);
return result;
});
diff --git a/frontend/src/components/Revision/RevisionDetailPanel.vue b/frontend/src/components/Revision/RevisionDetailPanel.vue
index 345932afac..bb0f356674 100644
--- a/frontend/src/components/Revision/RevisionDetailPanel.vue
+++ b/frontend/src/components/Revision/RevisionDetailPanel.vue
@@ -37,16 +37,17 @@
/>
</div>
- <div v-if="taskRun" class="my-4">
+ <div v-if="logEntries.length > 0" class="my-4">
<p class="w-auto flex items-center text-base text-main mb-2">
{{ $t("issue.task-run.logs") }}
</p>
- <TaskRunLogTable :task-run="taskRun" :sheet="sheet" />
+ <TaskRunLogViewer :entries="logEntries" :sheet="sheet" />
</div>
</template>
<script lang="ts" setup>
import { create } from "@bufbuild/protobuf";
+import { computedAsync } from "@vueuse/core";
import { computed, reactive, ref, watch } from "vue";
import { MonacoEditor } from "@/components/MonacoEditor";
import { CopyButton } from "@/components/v2";
@@ -54,10 +55,13 @@ import { rolloutServiceClientConnect } from "@/grpcweb";
import { useRevisionStore, useSheetV1Store } from "@/store";
import { type ComposedDatabase, getDateForPbTimestampProtoEs } from "@/types";
import type { TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
-import { GetTaskRunRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
+import {
+ GetTaskRunLogRequestSchema,
+ GetTaskRunRequestSchema,
+} from "@/types/proto-es/v1/rollout_service_pb";
import { extractIssueUID, getSheetStatement } from "@/utils";
-import TaskRunLogTable from "../IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue";
import HumanizeDate from "../misc/HumanizeDate.vue";
+import TaskRunLogViewer from "../Plan/components/RolloutView/v2/TaskRunLogViewer.vue";
interface LocalState {
loading: boolean;
@@ -104,6 +108,17 @@ watch(
{ immediate: true }
);
+// Fetch task run log
+const taskRunLog = computedAsync(async () => {
+ if (!taskRun.value?.name) return undefined;
+ const request = create(GetTaskRunLogRequestSchema, {
+ parent: taskRun.value.name,
+ });
+ return await rolloutServiceClientConnect.getTaskRunLog(request);
+}, undefined);
+
+const logEntries = computed(() => taskRunLog.value?.entries ?? []);
+
const revision = computed(() =>
revisionStore.getRevisionByName(props.revisionName)
);
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index d1c19d7d8f..a2aaafff23 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -106,7 +106,6 @@
"learn-more": "Learn more",
"troubleshoot": "Troubleshoot",
"schema-version": "Schema version",
- "time": "Time",
"Default": "Default",
"definition": "Definition",
"empty": "Empty",
@@ -357,8 +356,6 @@
"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}.",
@@ -373,6 +370,27 @@
"description": "Bytebase generates a rollback statement based on the task run. You can review the statement before executing the rollback."
},
"no-statement-generated": "No rollback statement generated"
+ },
+ "log-type": {
+ "schema-dump": "Schema Dump",
+ "command-execute": "Command Execute",
+ "database-sync": "Database Sync",
+ "status-update": "Status Update",
+ "transaction": "Transaction",
+ "prior-backup": "Prior Backup",
+ "retry": "Retry",
+ "compute-diff": "Compute Diff"
+ },
+ "log-detail": {
+ "dumping": "dumping...",
+ "syncing": "syncing...",
+ "waiting-to-execute": "waiting to execute",
+ "executing": "executing",
+ "status-changed": "status changed",
+ "backup-completed": "completed ({count} tables)",
+ "backing-up": "backing up...",
+ "retry-attempt": "attempt {current}/{max}",
+ "computing": "computing..."
}
},
"banner": {
@@ -1068,14 +1086,7 @@
"prior-backup": "Prior backup",
"retry-info": "Retry information",
"compute-diff": "Compute diff"
- },
- "affected-rows-n": "Affected rows: {n}",
- "prior-backup-tables": "Prior backup tables",
- "status-update": {
- "waiting": "Ready to be executed",
- "running": "Being executed"
- },
- "retry-info": "Retrying (attempt {n}/{m}) due to lock timeout."
+ }
},
"task-run-session": {
"blocking-sessions": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index fd4df12b25..cd8da00a3b 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -106,7 +106,6 @@
"learn-more": "Aprender más",
"troubleshoot": "Solucionar problemas",
"schema-version": "Versión de esquema",
- "time": "Tiempo",
"Default": "Predeterminado",
"definition": "Definición",
"empty": "Vacío",
@@ -357,8 +356,6 @@
"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.",
@@ -373,6 +370,27 @@
"description": "Bytebase genera una sentencia de reversión según la ejecución de la tarea. Puede revisar la sentencia antes de ejecutar la reversión."
},
"no-statement-generated": "No se generó ninguna declaración de reversión"
+ },
+ "log-type": {
+ "schema-dump": "Volcado de esquema",
+ "command-execute": "Comando Ejecutar",
+ "database-sync": "Sincronización de bases de datos",
+ "status-update": "Actualización de estado",
+ "transaction": "Transacción",
+ "prior-backup": "Copia de seguridad previa",
+ "retry": "Rever",
+ "compute-diff": "Calcular diferencia"
+ },
+ "log-detail": {
+ "dumping": "dumping...",
+ "syncing": "sincronizando...",
+ "waiting-to-execute": "esperando para ejecutar",
+ "executing": "ejecutando",
+ "status-changed": "estado cambiado",
+ "backup-completed": "completadas ({count} tablas)",
+ "backing-up": "haciendo copia de seguridad...",
+ "retry-attempt": "intento {current}/{max}",
+ "computing": "computación..."
}
},
"banner": {
@@ -1068,14 +1086,7 @@
"prior-backup": "Copia de seguridad previa",
"retry-info": "Reintento de información",
"compute-diff": "Calcular diff"
- },
- "affected-rows-n": "Filas afectadas: {n}",
- "prior-backup-tables": "Tablas de respaldo anteriores",
- "status-update": {
- "waiting": "Listo para ser ejecutado",
- "running": "Ser ejecutado"
- },
- "retry-info": "Vuelto (intento {n}/{m}) debido al tiempo de espera de bloqueo."
+ }
},
"task-run-session": {
"blocking-sessions": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index addfd5e9ab..8e9e317c14 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -106,7 +106,6 @@
"learn-more": "もっと詳しく知る",
"troubleshoot": "トラブルシューティング",
"schema-version": "スキーマのバージョン",
- "time": "時間",
"Default": "デフォルト",
"definition": "意味",
"empty": "空欄",
@@ -357,8 +356,6 @@
"history": "タスク実行履歴",
"latest-logs": "最新のログ",
"latest": "最新の実行",
- "showing-recent-logs": "最近の{count}ログを表示しています",
- "view-full-logs": "完全なログを表示",
"status": {
"enqueued": "処刑を待っています。",
"enqueued-with-rollout-time": "実行を待機しています。{time} の後に実行されます。",
@@ -373,6 +370,27 @@
"description": "Bytebaseはタスク実行に基づいてロールバックステートメントを生成します。ロールバックを実行する前にステートメントを確認できます。"
},
"no-statement-generated": "ロールバックステートメントは生成されません"
+ },
+ "log-type": {
+ "schema-dump": "スキーマダンプ",
+ "command-execute": "コマンド実行",
+ "database-sync": "データベース同期",
+ "status-update": "ステータスアップデート",
+ "transaction": "取引",
+ "prior-backup": "事前のバックアップ",
+ "retry": "リトライ",
+ "compute-diff": "差分計算"
+ },
+ "log-detail": {
+ "dumping": "ダンピング...",
+ "syncing": "同期中...",
+ "waiting-to-execute": "実行待ち",
+ "executing": "実行中",
+ "status-changed": "ステータスが変更されました",
+ "backup-completed": "完了しました({count} テーブル)",
+ "backing-up": "バックアップ中...",
+ "retry-attempt": "試行 {current}/{max}",
+ "computing": "コンピューティング..."
}
},
"banner": {
@@ -1068,14 +1086,7 @@
"prior-backup": "事前のバックアップ",
"retry-info": "情報を再試行します",
"compute-diff": "Diffを計算します"
- },
- "affected-rows-n": "影響行数: {n}",
- "prior-backup-tables": "以前のバックアップテーブル",
- "status-update": {
- "waiting": "実行の準備完了",
- "running": "処刑される"
- },
- "retry-info": "ロックタイムアウトのためにretrying({n}/{m}を試行)。"
+ }
},
"task-run-session": {
"blocking-sessions": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 2d4e98324e..2e99f26b3d 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -106,7 +106,6 @@
"learn-more": "Tìm hiểu thêm",
"troubleshoot": "Khắc phục sự cố",
"schema-version": "Phiên bản lược đồ",
- "time": "Thời gian",
"Default": "Mặc định",
"definition": "Định nghĩa",
"empty": "Trống",
@@ -357,8 +356,6 @@
"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}.",
@@ -373,6 +370,27 @@
"description": "Bytebase tạo ra một câu lệnh khôi phục dựa trên tác vụ đang chạy. Bạn có thể xem lại câu lệnh này trước khi thực hiện khôi phục."
},
"no-statement-generated": "Không có câu lệnh khôi phục nào được tạo ra"
+ },
+ "log-type": {
+ "schema-dump": "Sơ đồ đổ",
+ "command-execute": "Lệnh thực thi",
+ "database-sync": "Đồng bộ cơ sở dữ liệu",
+ "status-update": "Cập nhật trạng thái",
+ "transaction": "Giao dịch",
+ "prior-backup": "Sao lưu trước",
+ "retry": "Thử lại",
+ "compute-diff": "Tính toán chênh lệch"
+ },
+ "log-detail": {
+ "dumping": "đổ rác...",
+ "syncing": "đang đồng bộ hóa...",
+ "waiting-to-execute": "chờ đợi để thực hiện",
+ "executing": "thực hiện",
+ "status-changed": "trạng thái đã thay đổi",
+ "backup-completed": "đã hoàn thành ({count} bảng)",
+ "backing-up": "đang sao lưu...",
+ "retry-attempt": "nỗ lực {current}/{max}",
+ "computing": "tính toán..."
}
},
"banner": {
@@ -1068,14 +1086,7 @@
"prior-backup": "Sao lưu trước",
"retry-info": "Thông tin thử lại",
"compute-diff": "Tính toán khác"
- },
- "affected-rows-n": "Số dòng bị ảnh hưởng: {n}",
- "prior-backup-tables": "Bảng sao lưu trước",
- "status-update": {
- "waiting": "Sẵn sàng để thực thi",
- "running": "Đang được thực thi"
- },
- "retry-info": "Thử lại (cố gắng {n}/{m}) do thời gian chờ khóa."
+ }
},
"task-run-session": {
"blocking-sessions": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 6ced687adf..5ac236138e 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -106,7 +106,6 @@
"learn-more": "了解更多",
"troubleshoot": "排查问题",
"schema-version": "Schema 版本",
- "time": "时间",
"Default": "默认",
"definition": "定义",
"empty": "空",
@@ -357,8 +356,6 @@
"history": "执行记录",
"latest-logs": "执行日志",
"latest": "最新执行",
- "showing-recent-logs": "显示最近 {count} 条日志",
- "view-full-logs": "查看完整日志",
"status": {
"enqueued": "等待执行。",
"enqueued-with-rollout-time": "等待执行,{time}后执行。",
@@ -373,6 +370,27 @@
"description": "Bytebase 根据任务运行情况生成回滚语句,您可以在执行回滚前查看该语句。"
},
"no-statement-generated": "生成的回滚语句为空"
+ },
+ "log-type": {
+ "schema-dump": "结构导出",
+ "command-execute": "命令执行",
+ "database-sync": "数据库同步",
+ "status-update": "状态更新",
+ "transaction": "事务",
+ "prior-backup": "预备份",
+ "retry": "重试",
+ "compute-diff": "计算差异"
+ },
+ "log-detail": {
+ "dumping": "导出中...",
+ "syncing": "同步中...",
+ "waiting-to-execute": "等待执行",
+ "executing": "执行中",
+ "status-changed": "状态变更",
+ "backup-completed": "已完成({count} 个表)",
+ "backing-up": "备份中...",
+ "retry-attempt": "第 {current}/{max} 次尝试",
+ "computing": "计算中..."
}
},
"banner": {
@@ -1068,14 +1086,7 @@
"prior-backup": "数据预备份",
"retry-info": "重试信息",
"compute-diff": "计算差异"
- },
- "affected-rows-n": "影响行数:{n}",
- "prior-backup-tables": "数据预备份相关的表",
- "status-update": {
- "waiting": "准备就绪,等待执行",
- "running": "开始执行"
- },
- "retry-info": "锁超时重试(尝试{n}/{m})。"
+ }
},
"task-run-session": {
"blocking-sessions": {
diff --git a/frontend/src/utils/v1/taskRunLog.ts b/frontend/src/utils/v1/taskRunLog.ts
new file mode 100644
index 0000000000..9c2180d0fe
--- /dev/null
+++ b/frontend/src/utils/v1/taskRunLog.ts
@@ -0,0 +1,34 @@
+import { t } from "@/plugins/i18n";
+import { TaskRunLogEntry_Type } from "@/types/proto-es/v1/rollout_service_pb";
+
+export const displayTaskRunLogEntryType = (type: TaskRunLogEntry_Type) => {
+ if (type === TaskRunLogEntry_Type.COMMAND_EXECUTE) {
+ return t("issue.task-run.task-run-log.entry-type.command-execute");
+ }
+ if (type === TaskRunLogEntry_Type.SCHEMA_DUMP) {
+ return t("issue.task-run.task-run-log.entry-type.schema-dump");
+ }
+ if (type === TaskRunLogEntry_Type.TASK_RUN_STATUS_UPDATE) {
+ return t("issue.task-run.task-run-log.entry-type.task-run-status-update");
+ }
+ if (type === TaskRunLogEntry_Type.TRANSACTION_CONTROL) {
+ return t("issue.task-run.task-run-log.entry-type.transaction-control");
+ }
+ if (type === TaskRunLogEntry_Type.DATABASE_SYNC) {
+ return t("issue.task-run.task-run-log.entry-type.database-sync");
+ }
+ if (type === TaskRunLogEntry_Type.PRIOR_BACKUP) {
+ return t("issue.task-run.task-run-log.entry-type.prior-backup");
+ }
+ if (type === TaskRunLogEntry_Type.COMPUTE_DIFF) {
+ return t("issue.task-run.task-run-log.entry-type.compute-diff");
+ }
+ if (type === TaskRunLogEntry_Type.RETRY_INFO) {
+ return t("issue.task-run.task-run-log.entry-type.retry-info");
+ }
+
+ console.warn(
+ `[displayTaskRunLogEntryType] should never reach this line: type=${TaskRunLogEntry_Type[type]}`
+ );
+ return "";
+};