Skip to content

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

refactor(frontend): simplify TaskRunLogViewer API and improve data fetching (#18834)

boojack87c5fdde43d2
diff --git a/frontend/src/components/Changelog/ChangelogDetail.vue b/frontend/src/components/Changelog/ChangelogDetail.vue
index afc12b0f25..086b46e88f 100644
--- a/frontend/src/components/Changelog/ChangelogDetail.vue
+++ b/frontend/src/components/Changelog/ChangelogDetail.vue
@@ -43,12 +43,9 @@
<ArrowUpRightIcon class="w-4 h-4" />
</router-link>
</div>
- <div v-if="isFetchingTaskRunLog" class="py-2 text-gray-500 text-sm">
- {{ $t("common.loading") }}
- </div>
<TaskRunLogViewer
- v-else-if="taskRunLogEntries.length > 0"
- :entries="taskRunLogEntries"
+ v-if="changelog?.taskRun && showTaskRunLogs"
+ :task-run-name="changelog.taskRun"
/>
<div v-else class="text-sm text-control-light">
{{ $t("common.no-data") }}
@@ -118,18 +115,15 @@
</template>
<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import { computedAsync } from "@vueuse/core";
import { ArrowUpRightIcon } from "lucide-vue-next";
import { NButton, NSwitch } from "naive-ui";
-import { computed, reactive, ref, unref, watch } from "vue";
+import { computed, reactive, unref, watch } from "vue";
import { useRouter } from "vue-router";
import { BBSpin } from "@/bbkit";
import { useDatabaseDetailContext } from "@/components/Database/context";
import { DiffEditor, MonacoEditor } from "@/components/MonacoEditor";
import { TaskRunLogViewer } from "@/components/RolloutV1/components/TaskRunLogViewer";
import { CopyButton } from "@/components/v2";
-import { rolloutServiceClientConnect } from "@/connect";
import { PROJECT_V1_ROUTE_SYNC_SCHEMA } from "@/router/dashboard/projectV1";
import {
useChangelogStore,
@@ -143,7 +137,6 @@ import {
Changelog_Type,
ChangelogView,
} from "@/types/proto-es/v1/database_service_pb";
-import { GetTaskRunLogRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
import {
bytesToString,
extractProjectResourceName,
@@ -249,29 +242,14 @@ const allowRollback = computed((): boolean => {
);
});
-// Fetch task run log for completed/failed changelogs
-const isFetchingTaskRunLog = ref(false);
-const taskRunLog = computedAsync(
- async () => {
- const taskRunName = changelog.value?.taskRun;
- if (!taskRunName) return undefined;
- // Only fetch logs for completed or failed changelogs
- if (
- changelog.value?.status !== Changelog_Status.DONE &&
- changelog.value?.status !== Changelog_Status.FAILED
- ) {
- return undefined;
- }
- const request = create(GetTaskRunLogRequestSchema, {
- parent: taskRunName,
- });
- return await rolloutServiceClientConnect.getTaskRunLog(request);
- },
- undefined,
- { evaluating: isFetchingTaskRunLog }
-);
-
-const taskRunLogEntries = computed(() => taskRunLog.value?.entries ?? []);
+// Only show task run logs for completed or failed changelogs
+const showTaskRunLogs = computed(() => {
+ if (!changelog.value?.taskRun) return false;
+ return (
+ changelog.value.status === Changelog_Status.DONE ||
+ changelog.value.status === Changelog_Status.FAILED
+ );
+});
const handleRollback = () => {
if (!changelog.value || !database.value) {
diff --git a/frontend/src/components/Revision/RevisionDetailPanel.vue b/frontend/src/components/Revision/RevisionDetailPanel.vue
index e3c018b301..dc70e4fc43 100644
--- a/frontend/src/components/Revision/RevisionDetailPanel.vue
+++ b/frontend/src/components/Revision/RevisionDetailPanel.vue
@@ -34,33 +34,23 @@
</div>
</div>
- <div v-if="logEntries.length > 0" class="my-4">
+ <div v-if="revision?.taskRun" class="my-4">
<p class="w-auto flex items-center text-base text-main mb-2">
{{ $t("issue.task-run.logs") }}
</p>
- <TaskRunLogViewer :entries="logEntries" :sheet="fetchedSheet" />
+ <TaskRunLogViewer :task-run-name="revision.taskRun" />
</div>
</template>
<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import { computedAsync } from "@vueuse/core";
import { NSpin } from "naive-ui";
import { computed, ref, watch } from "vue";
import { MonacoEditor } from "@/components/MonacoEditor";
import { TaskRunLogViewer } from "@/components/RolloutV1/components/TaskRunLogViewer";
import { CopyButton } from "@/components/v2";
-import {
- rolloutServiceClientConnect,
- sheetServiceClientConnect,
-} from "@/connect";
+import { sheetServiceClientConnect } from "@/connect";
import { useRevisionStore } from "@/store";
import { type ComposedDatabase, getDateForPbTimestampProtoEs } from "@/types";
-import type { TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
-import {
- GetTaskRunLogRequestSchema,
- GetTaskRunRequestSchema,
-} from "@/types/proto-es/v1/rollout_service_pb";
import HumanizeDate from "../misc/HumanizeDate.vue";
const props = defineProps<{
@@ -68,14 +58,10 @@ const props = defineProps<{
revisionName: string;
}>();
-import { type Sheet } from "@/types/proto-es/v1/sheet_service_pb";
-
const loading = ref(false);
const fetchedStatement = ref("");
-const fetchedSheet = ref<Sheet | undefined>(undefined);
const revisionStore = useRevisionStore();
-const taskRun = ref<TaskRun | undefined>(undefined);
watch(
() => props.revisionName,
@@ -86,30 +72,18 @@ watch(
loading.value = true;
fetchedStatement.value = "";
- fetchedSheet.value = undefined;
try {
const revision =
await revisionStore.getOrFetchRevisionByName(revisionName);
if (revision) {
- if (revision.taskRun) {
- // Fetch the task run details.
- const request = create(GetTaskRunRequestSchema, {
- name: revision.taskRun,
- });
- const response =
- await rolloutServiceClientConnect.getTaskRun(request);
- taskRun.value = response;
- }
- // Prepare the sheet data from task run.
- // We fetch raw content directly.
+ // Prepare the sheet data for statement display
if (revision.sheet) {
try {
const sheet = await sheetServiceClientConnect.getSheet({
name: revision.sheet,
raw: true,
});
- fetchedSheet.value = sheet;
if (sheet.content) {
fetchedStatement.value = new TextDecoder().decode(sheet.content);
}
@@ -127,17 +101,6 @@ 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/components/RolloutV1/components/LatestTaskRunInfo.vue b/frontend/src/components/RolloutV1/components/LatestTaskRunInfo.vue
index 4cfa6b81fc..b00d2a500f 100644
--- a/frontend/src/components/RolloutV1/components/LatestTaskRunInfo.vue
+++ b/frontend/src/components/RolloutV1/components/LatestTaskRunInfo.vue
@@ -50,9 +50,8 @@
<!-- Line 2: Task run logs -->
<TaskRunLogViewer
- v-if="summary.entries.length > 0"
- :entries="summary.entries"
- :sheet="sheet"
+ v-if="taskRunName && summary.entries.length > 0"
+ :task-run-name="taskRunName"
/>
</div>
</template>
@@ -74,7 +73,6 @@ import { computed, h } from "vue";
import { useI18n } from "vue-i18n";
import Timestamp from "@/components/misc/Timestamp.vue";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
-import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
import type { TaskRunLogSummary } from "./composables/useTaskRunLogSummary";
import { TaskRunLogViewer } from "./TaskRunLogViewer";
@@ -154,12 +152,11 @@ const STATUS_CONFIG: Record<Task_Status, StatusConfig> = {
const props = defineProps<{
status: Task_Status;
updateTime?: TimestampType;
- sheet?: Sheet;
+ taskRunName?: string;
executorEmail?: string;
duration?: string;
affectedRowsDisplay?: string;
summary: TaskRunLogSummary;
- taskName?: string;
}>();
const { t } = useI18n();
diff --git a/frontend/src/components/RolloutV1/components/TaskItem.vue b/frontend/src/components/RolloutV1/components/TaskItem.vue
index 6d9903470a..667a895a19 100644
--- a/frontend/src/components/RolloutV1/components/TaskItem.vue
+++ b/frontend/src/components/RolloutV1/components/TaskItem.vue
@@ -194,12 +194,11 @@
v-if="latestTaskRun"
:status="task.status"
:update-time="latestTaskRun.updateTime"
- :sheet="taskSheet"
+ :task-run-name="latestTaskRun.name"
:executor-email="executorEmail"
:duration="timingType !== 'scheduled' ? timingDisplay : undefined"
:affected-rows-display="affectedRowsDisplay"
:summary="taskRunLogSummary"
- :task-name="task.name"
/>
</div>
</div>
@@ -238,7 +237,7 @@ import { usePlanContextWithRollout } from "@/components/Plan";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import { PROJECT_V1_ROUTE_PLAN_ROLLOUT_TASK } from "@/router/dashboard/projectV1";
-import { taskRunNamePrefix, useSheetV1Store } from "@/store";
+import { taskRunNamePrefix } from "@/store";
import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
@@ -249,7 +248,6 @@ import {
extractTaskUID,
isReleaseBasedTask,
releaseNameOfTaskV1,
- sheetNameOfTaskV1,
} from "@/utils";
import { useTaskActions } from "./composables/useTaskActions";
import { useTaskDisplay } from "./composables/useTaskDisplay";
@@ -335,14 +333,6 @@ const { loading, displayedStatement, isStatementTruncated } = useTaskStatement(
() => props.isExpanded
);
-// Get sheet for extracting individual commands in log display
-const sheetStore = useSheetV1Store();
-const taskSheet = computed(() => {
- const sheetName = sheetNameOfTaskV1(props.task);
- if (!sheetName) return undefined;
- return sheetStore.getSheetByName(sheetName);
-});
-
const latestTaskRun = computed(() => {
const taskRunsForTask = allTaskRuns.value.filter((run) =>
run.name.startsWith(`${props.task.name}/${taskRunNamePrefix}`)
diff --git a/frontend/src/components/RolloutV1/components/TaskRunDetail.vue b/frontend/src/components/RolloutV1/components/TaskRunDetail.vue
index 8cdafe82c3..0d9af1e10a 100644
--- a/frontend/src/components/RolloutV1/components/TaskRunDetail.vue
+++ b/frontend/src/components/RolloutV1/components/TaskRunDetail.vue
@@ -2,14 +2,10 @@
<NTabs v-model:value="state.currentTab" type="line">
<NTabPane name="LOG" :tab="$t('issue.task-run.logs')">
<TaskRunLogViewer
- v-if="logEntries.length > 0"
+ v-if="taskRun.name"
:key="componentId"
- :entries="logEntries"
- :sheet="sheet"
+ :task-run-name="taskRun.name"
/>
- <div v-else-if="isFetching" class="py-4 text-gray-500 text-sm">
- {{ $t("common.loading") }}
- </div>
</NTabPane>
<NTabPane
v-if="showTaskRunSessionTab"
@@ -31,21 +27,16 @@
</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 } from "vue";
-import { rolloutServiceClientConnect } from "@/connect";
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 type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
import { TaskRunLogViewer } from "./TaskRunLogViewer";
import TaskRunSession from "./TaskRunSession";
@@ -66,27 +57,6 @@ const state = reactive<LocalState>({
// Mainly using to force re-render of TaskRunSession component which will re-fetch the session data.
const componentId = ref<string>(uniqueId());
-// Sheet is no longer available on TaskRun - it should be fetched from the parent Task
-// For now, we'll make it undefined. Components using this should get the sheet from
-// the task context if needed.
-const sheet = ref<Sheet | undefined>(undefined);
-
-// 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();
};
diff --git a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/TaskRunLogViewer.vue b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/TaskRunLogViewer.vue
index d8d1e556a0..d7ba0ab04a 100644
--- a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/TaskRunLogViewer.vue
+++ b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/TaskRunLogViewer.vue
@@ -215,17 +215,20 @@ import {
ListIcon,
ServerIcon,
} from "lucide-vue-next";
-import type { TaskRunLogEntry } from "@/types/proto-es/v1/rollout_service_pb";
-import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
import SectionContent from "./SectionContent.vue";
import SectionHeader from "./SectionHeader.vue";
+import { useTaskRunLogData } from "./useTaskRunLogData";
import { useTaskRunLogSections } from "./useTaskRunLogSections";
const props = defineProps<{
- entries: TaskRunLogEntry[];
- sheet?: Sheet;
+ taskRunName: string;
}>();
+// Fetch task run log entries and sheets internally
+const { entries, sheet, sheetsMap } = useTaskRunLogData(
+ () => props.taskRunName
+);
+
const {
sections,
hasMultipleReplicas,
@@ -244,8 +247,9 @@ const {
totalSections,
totalEntries,
} = useTaskRunLogSections(
- () => props.entries,
- () => props.sheet
+ () => entries.value,
+ () => sheet.value,
+ () => sheetsMap.value
);
const toggleExpandAll = () => {
diff --git a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/index.ts b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/index.ts
index 508972392f..144e97948e 100644
--- a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/index.ts
+++ b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/index.ts
@@ -1,3 +1,2 @@
export { default as TaskRunLogViewer } from "./TaskRunLogViewer.vue";
export * from "./types";
-export * from "./useTaskRunLogSections";
diff --git a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogData.ts b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogData.ts
new file mode 100644
index 0000000000..0764f1536c
--- /dev/null
+++ b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogData.ts
@@ -0,0 +1,165 @@
+import { create } from "@bufbuild/protobuf";
+import { computedAsync } from "@vueuse/core";
+import type { MaybeRefOrGetter, Ref } from "vue";
+import { computed, ref, toValue, watch } from "vue";
+import {
+ rolloutServiceClientConnect,
+ sheetServiceClientConnect,
+} from "@/connect";
+import { useReleaseStore, useRolloutByName } from "@/store";
+import {
+ GetTaskRunLogRequestSchema,
+ type TaskRunLogEntry,
+} from "@/types/proto-es/v1/rollout_service_pb";
+import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
+import {
+ extractRolloutNameFromTaskRunName,
+ extractTaskNameFromTaskRunName,
+ isReleaseBasedTask,
+ releaseNameOfTaskV1,
+ sheetNameOfTaskV1,
+} from "@/utils";
+
+export interface UseTaskRunLogDataReturn {
+ entries: Ref<TaskRunLogEntry[]>;
+ sheet: Ref<Sheet | undefined>;
+ sheetsMap: Ref<Map<string, Sheet>>;
+}
+
+/**
+ * Composable that fetches task run log entries and associated sheets.
+ * Handles both regular tasks (single sheet) and release tasks (multiple sheets by version).
+ */
+export const useTaskRunLogData = (
+ taskRunName: MaybeRefOrGetter<string | undefined>
+): UseTaskRunLogDataReturn => {
+ const releaseStore = useReleaseStore();
+
+ // Sheet for non-release tasks
+ const sheet = ref<Sheet | undefined>(undefined);
+ // Map of version -> Sheet for release tasks
+ const sheetsMap = ref<Map<string, Sheet>>(new Map());
+
+ // Fetch task run log entries
+ const taskRunLog = computedAsync(async () => {
+ const name = toValue(taskRunName);
+ if (!name) return undefined;
+ const request = create(GetTaskRunLogRequestSchema, {
+ parent: name,
+ });
+ return await rolloutServiceClientConnect.getTaskRunLog(request);
+ }, undefined);
+
+ const entries = computed(() => taskRunLog.value?.entries ?? []);
+
+ // Extract rollout name from task run name to get the task
+ const rolloutName = computed(() => {
+ const name = toValue(taskRunName);
+ if (!name) return "";
+ return extractRolloutNameFromTaskRunName(name);
+ });
+
+ const { rollout } = useRolloutByName(rolloutName);
+
+ // Find the task from the rollout
+ const task = computed(() => {
+ const name = toValue(taskRunName);
+ if (!name || !rollout.value) return undefined;
+
+ const taskName = extractTaskNameFromTaskRunName(name);
+ if (!taskName) return undefined;
+
+ for (const stage of rollout.value.stages) {
+ const foundTask = stage.tasks.find((t) => t.name === taskName);
+ if (foundTask) return foundTask;
+ }
+ return undefined;
+ });
+
+ // Track fetch version to handle race conditions
+ let fetchVersion = 0;
+
+ // Fetch sheet(s) based on task type
+ watch(
+ task,
+ async (currentTask) => {
+ const currentFetchVersion = ++fetchVersion;
+
+ if (!currentTask) {
+ sheet.value = undefined;
+ sheetsMap.value = new Map();
+ return;
+ }
+
+ if (isReleaseBasedTask(currentTask)) {
+ // Release task: fetch release and build sheets map by version
+ const releaseName = releaseNameOfTaskV1(currentTask);
+ if (!releaseName) return;
+
+ try {
+ const release = await releaseStore.fetchReleaseByName(
+ releaseName,
+ true
+ );
+ // Abort if a newer fetch has started
+ if (currentFetchVersion !== fetchVersion) return;
+
+ // Fetch all sheets in parallel
+ const filesToFetch = release.files.filter(
+ (f) => f.sheet && f.version
+ );
+ const sheetPromises = filesToFetch.map(async (file) => {
+ try {
+ const fetchedSheet = await sheetServiceClientConnect.getSheet({
+ name: file.sheet,
+ raw: true,
+ });
+ return { version: file.version, sheet: fetchedSheet };
+ } catch {
+ return null;
+ }
+ });
+
+ const results = await Promise.all(sheetPromises);
+ // Abort if a newer fetch has started
+ if (currentFetchVersion !== fetchVersion) return;
+
+ const newSheetsMap = new Map<string, Sheet>();
+ for (const result of results) {
+ if (result?.sheet) {
+ newSheetsMap.set(result.version, result.sheet);
+ }
+ }
+ sheetsMap.value = newSheetsMap;
+ } catch {
+ // Ignore release fetch errors
+ }
+ } else {
+ // Non-release task: fetch single sheet
+ const sheetName = sheetNameOfTaskV1(currentTask);
+ if (!sheetName) return;
+
+ try {
+ const fetchedSheet = await sheetServiceClientConnect.getSheet({
+ name: sheetName,
+ raw: true,
+ });
+ // Abort if a newer fetch has started
+ if (currentFetchVersion !== fetchVersion) return;
+ sheet.value = fetchedSheet;
+ } catch {
+ if (currentFetchVersion === fetchVersion) {
+ sheet.value = undefined;
+ }
+ }
+ }
+ },
+ { immediate: true }
+ );
+
+ return {
+ entries,
+ sheet,
+ sheetsMap,
+ };
+};
diff --git a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogSections.ts b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogSections.ts
index d2179be79d..ae8e0ef552 100644
--- a/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogSections.ts
+++ b/frontend/src/components/RolloutV1/components/TaskRunLogViewer/useTaskRunLogSections.ts
@@ -67,7 +67,8 @@ export interface UseTaskRunLogSectionsReturn {
export const useTaskRunLogSections = (
entries: MaybeRefOrGetter<TaskRunLogEntry[]>,
- sheet: MaybeRefOrGetter<Sheet | undefined>
+ sheet: MaybeRefOrGetter<Sheet | undefined>,
+ sheetsMap: MaybeRefOrGetter<Map<string, Sheet> | undefined> = () => undefined
): UseTaskRunLogSectionsReturn => {
const { t } = useI18n();
@@ -100,7 +101,34 @@ export const useTaskRunLogSections = (
return labelMap[type] ?? "Unknown";
};
- const getEntryDetail = (entry: TaskRunLogEntry): string => {
+ // Extract statement from sheet content using byte range
+ const extractStatementFromRange = (
+ range: { start: number; end: number },
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
+ fileVersion?: string
+ ): string | undefined => {
+ // For release tasks, look up sheet by version from sheetsMap
+ // For non-release tasks, use the single sheet
+ let content = sheetContent;
+ if (fileVersion && sheetsMapValue) {
+ const fileSheet = sheetsMapValue.get(fileVersion);
+ if (fileSheet?.content) {
+ content = fileSheet.content;
+ }
+ }
+ if (!content) return undefined;
+
+ const subarray = content.subarray(range.start, range.end);
+ return new TextDecoder().decode(subarray);
+ };
+
+ const getEntryDetail = (
+ entry: TaskRunLogEntry,
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
+ fileVersion?: string
+ ): string => {
switch (entry.type) {
case TaskRunLogEntry_Type.COMMAND_EXECUTE: {
const cmd = entry.commandExecute;
@@ -111,14 +139,12 @@ export const useTaskRunLogSections = (
if (cmd.statement) {
statement = cmd.statement;
} else if (cmd.range) {
- const sheetValue = toValue(sheet);
- if (sheetValue) {
- const subarray = sheetValue.content.subarray(
- cmd.range.start,
- cmd.range.end
- );
- statement = new TextDecoder().decode(subarray);
- }
+ statement = extractStatementFromRange(
+ cmd.range,
+ sheetContent,
+ sheetsMapValue,
+ fileVersion
+ );
}
if (statement) {
const stmt = statement.trim().replace(/\s+/g, " ");
@@ -196,7 +222,10 @@ export const useTaskRunLogSections = (
const buildDisplayItems = (
groupEntries: TaskRunLogEntry[],
groupIdx: number,
- startTime: number
+ startTime: number,
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
+ fileVersion?: string
): DisplayItem[] => {
return groupEntries.map((entry, idx) => {
const entryTime = getTimestampMs(entry.logTime);
@@ -209,7 +238,12 @@ export const useTaskRunLogSections = (
relativeTime: relativeMs > 0 ? formatRelativeTime(relativeMs) : "",
levelIndicator: entryHasError ? "\u2717" : "\u2713",
levelClass: entryHasError ? "text-red-600" : "text-green-600",
- detail: getEntryDetail(entry),
+ detail: getEntryDetail(
+ entry,
+ sheetContent,
+ sheetsMapValue,
+ fileVersion
+ ),
detailClass: entryHasError ? "text-red-700" : "text-gray-600",
affectedRows:
entry.type === TaskRunLogEntry_Type.COMMAND_EXECUTE
@@ -233,8 +267,11 @@ export const useTaskRunLogSections = (
const buildSectionsFromEntries = (
entriesList: TaskRunLogEntry[],
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
idPrefix = "",
- forceError = false
+ forceError = false,
+ fileVersion?: string
): Section[] => {
if (!entriesList.length) return [];
@@ -256,7 +293,14 @@ export const useTaskRunLogSections = (
const endTime = timestamps.length ? Math.max(...timestamps) : 0;
const durationMs = endTime - startTime;
- const items = buildDisplayItems(groupEntries, groupIdx, startTime);
+ const items = buildDisplayItems(
+ groupEntries,
+ groupIdx,
+ startTime,
+ sheetContent,
+ sheetsMapValue,
+ fileVersion
+ );
const statusCfg = STATUS_CONFIG[status];
return {
@@ -277,7 +321,9 @@ export const useTaskRunLogSections = (
const sections = computed((): Section[] => {
const entriesValue = toValue(entries);
- return buildSectionsFromEntries(entriesValue);
+ const sheetContent = toValue(sheet)?.content;
+ const sheetsMapValue = toValue(sheetsMap);
+ return buildSectionsFromEntries(entriesValue, sheetContent, sheetsMapValue);
});
const hasMultipleReplicas = computed((): boolean => {
@@ -294,6 +340,8 @@ export const useTaskRunLogSections = (
// Build release file groups from entries
const buildReleaseFileGroupsFromEntries = (
entriesList: TaskRunLogEntry[],
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
idPrefix = "",
forceError = false
): ReleaseFileGroup[] => {
@@ -303,10 +351,19 @@ export const useTaskRunLogSections = (
.filter((group) => group.file !== null) // Only include groups with file markers
.map((group, idx) => {
const fileId = idPrefix ? `${idPrefix}-file-${idx}` : `file-${idx}`;
+ const version = group.file!.version;
return {
- version: group.file!.version,
+ version,
filePath: group.file!.filePath,
- sections: buildSectionsFromEntries(group.entries, fileId, forceError),
+ // Pass version so COMMAND_EXECUTE entries can look up the correct sheet
+ sections: buildSectionsFromEntries(
+ group.entries,
+ sheetContent,
+ sheetsMapValue,
+ fileId,
+ forceError,
+ version
+ ),
};
});
};
@@ -314,6 +371,8 @@ export const useTaskRunLogSections = (
// Get orphan sections (entries before any release file marker)
const getOrphanSections = (
entriesList: TaskRunLogEntry[],
+ sheetContent: Uint8Array | undefined,
+ sheetsMapValue: Map<string, Sheet> | undefined,
idPrefix = "",
forceError = false
): Section[] => {
@@ -324,6 +383,8 @@ export const useTaskRunLogSections = (
}
return buildSectionsFromEntries(
orphanGroup.entries,
+ sheetContent,
+ sheetsMapValue,
idPrefix ? `${idPrefix}-orphan` : "orphan",
forceError
);
@@ -333,7 +394,13 @@ export const useTaskRunLogSections = (
const releaseFileGroups = computed((): ReleaseFileGroup[] => {
const entriesValue = toValue(entries);
if (!hasReleaseFileMarkers(entriesValue)) return [];
- return buildReleaseFileGroupsFromEntries(entriesValue);
+ const sheetContent = toValue(sheet)?.content;
+ const sheetsMapValue = toValue(sheetsMap);
+ return buildReleaseFileGroupsFromEntries(
+ entriesValue,
+ sheetContent,
+ sheetsMapValue
+ );
});
const replicaGroups = computed((): ReplicaGroup[] => {
@@ -343,6 +410,8 @@ export const useTaskRunLogSections = (
const replicaIds = getUniqueReplicaIds(entriesValue);
if (replicaIds.length <= 1) return [];
+ const sheetContent = toValue(sheet)?.content;
+ const sheetsMapValue = toValue(sheetsMap);
const entriesByReplica = groupEntriesByReplica(entriesValue);
return replicaIds.map((replicaId, idx) => {
@@ -358,10 +427,18 @@ export const useTaskRunLogSections = (
replicaId,
releaseFileGroups: buildReleaseFileGroupsFromEntries(
replicaEntries,
+ sheetContent,
+ sheetsMapValue,
+ replicaId,
+ forceError
+ ),
+ sections: getOrphanSections(
+ replicaEntries,
+ sheetContent,
+ sheetsMapValue,
replicaId,
forceError
),
- sections: getOrphanSections(replicaEntries, replicaId, forceError),
};
}
@@ -370,6 +447,8 @@ export const useTaskRunLogSections = (
releaseFileGroups: [],
sections: buildSectionsFromEntries(
replicaEntries,
+ sheetContent,
+ sheetsMapValue,
replicaId,
forceError
),
diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.ts
index d51d553591..60b8dfcbcf 100644
--- a/frontend/src/utils/v1/issue/rollout.ts
+++ b/frontend/src/utils/v1/issue/rollout.ts
@@ -79,6 +79,30 @@ export const extractTaskRunUID = (name: string) => {
return matches?.[1] ?? "";
};
+/**
+ * Extracts the rollout resource name from a task run resource name.
+ * Task run name format: projects/{project}/plans/{plan}/rollout/stages/{stage}/tasks/{task}/taskRuns/{taskRun}
+ * Returns: projects/{project}/plans/{plan}/rollout
+ */
+export const extractRolloutNameFromTaskRunName = (
+ taskRunName: string
+): string => {
+ const pattern = /^(projects\/[^/]+\/plans\/[^/]+\/rollout)\/stages\//;
+ const matches = taskRunName.match(pattern);
+ return matches?.[1] ?? "";
+};
+
+/**
+ * Extracts the task resource name from a task run resource name.
+ * Task run name format: projects/{project}/plans/{plan}/rollout/stages/{stage}/tasks/{task}/taskRuns/{taskRun}
+ * Returns: projects/{project}/plans/{plan}/rollout/stages/{stage}/tasks/{task}
+ */
+export const extractTaskNameFromTaskRunName = (taskRunName: string): string => {
+ const idx = taskRunName.lastIndexOf("/taskRuns/");
+ if (idx === -1) return "";
+ return taskRunName.substring(0, idx);
+};
+
export const stageV1Slug = (stage: Stage): string => {
// Stage UID is now the environment ID
return extractStageUID(stage.name);