forked from xhgit/webup-cloud
Show actual file changes recorded for each Agent task
This commit is contained in:
1 parent
d04777247b
commit
3296d378c9
14 files changed
+453
-16
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, reactive, ref, watch } from "vue";
|
||||
import { api, body } from "../api";
|
||||
import TaskChanges from "./TaskChanges.vue";
|
||||
const projects = ref<any[]>([]),
|
||||
models = ref<any[]>([]),
|
||||
tasks = ref<any[]>([]),
|
||||
@@ -632,6 +633,13 @@ onUnmounted(() => clearInterval(timer));
|
||||
跳到最新日志
|
||||
</button>
|
||||
</section>
|
||||
<TaskChanges
|
||||
v-if="selected"
|
||||
:key="selected.id"
|
||||
:task-id="selected.id"
|
||||
:event-id="events.at(-1)?.id"
|
||||
:status="selected.status"
|
||||
/>
|
||||
<section class="panel form-panel">
|
||||
<div class="panel-heading">
|
||||
<h3>项目文件与版本</h3>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { api } from "../api";
|
||||
|
||||
type FileChange = {
|
||||
file_path: string;
|
||||
last_status: "ADDED" | "MODIFIED" | "DELETED";
|
||||
added_lines: number;
|
||||
removed_lines: number;
|
||||
binary_change: boolean;
|
||||
};
|
||||
type ChangeReport = {
|
||||
checks: number;
|
||||
partial: boolean;
|
||||
totals: { file_count: number; added_lines: number; removed_lines: number };
|
||||
files: FileChange[];
|
||||
};
|
||||
const props = defineProps<{ taskId: string; eventId?: string; status: string }>();
|
||||
const report = ref<ChangeReport>();
|
||||
const page = ref(0);
|
||||
const loading = ref(false);
|
||||
const error = ref("");
|
||||
const labels = { ADDED: "新增", MODIFIED: "修改", DELETED: "删除" };
|
||||
|
||||
watch(
|
||||
[() => props.taskId, () => props.eventId, () => props.status, page],
|
||||
async (_, previous, onCleanup) => {
|
||||
let current = true;
|
||||
onCleanup(() => { current = false; });
|
||||
if (previous?.[0] !== props.taskId || previous?.[3] !== page.value) report.value = undefined;
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const result = await api<ChangeReport>(`/tasks/${props.taskId}/changes?page=${page.value}`);
|
||||
if (current) report.value = result;
|
||||
} catch (cause) {
|
||||
if (current) error.value = (cause as Error).message;
|
||||
} finally {
|
||||
if (current) loading.value = false;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="panel table-panel" :aria-busy="loading">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<h3>Agent 文件变更</h3>
|
||||
<p>只统计此任务中 Agent 工具造成的改动,行数按每次操作累计。</p>
|
||||
</div>
|
||||
<span v-if="report?.checks" class="totals">
|
||||
{{ report.totals.file_count }} 个文件 ·
|
||||
<span class="good">+{{ report.totals.added_lines }}</span> /
|
||||
<span class="danger">−{{ report.totals.removed_lines }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="error" class="alert error" role="alert">{{ error }}</p>
|
||||
<p v-if="report?.partial" class="alert info">部分操作未能取得完整统计,以下为已记录的变更。</p>
|
||||
<div v-if="report?.files.length" class="table-scroll">
|
||||
<table class="change-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">文件</th>
|
||||
<th scope="col">最后操作</th>
|
||||
<th scope="col">新增行</th>
|
||||
<th scope="col">删除行</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="file in report.files" :key="file.file_path">
|
||||
<td class="change-path"><code>{{ file.file_path }}</code></td>
|
||||
<td>{{ labels[file.last_status] }}{{ file.binary_change ? " · 含二进制改动" : "" }}</td>
|
||||
<td class="good">+{{ file.added_lines }}</td>
|
||||
<td class="danger">−{{ file.removed_lines }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p v-else-if="!error" class="empty">
|
||||
{{ loading ? "正在读取变更…" : report?.checks && !report.partial ? "Agent 尚未改动文件。" : "此任务暂无可用的变更记录。" }}
|
||||
</p>
|
||||
<div v-if="page > 0 || (report?.totals.file_count ?? 0) > 100" class="table-actions">
|
||||
<button class="secondary" :disabled="page === 0 || loading" @click="page--">上一页</button>
|
||||
<span class="muted">第 {{ page + 1 }} 页</span>
|
||||
<button class="secondary" :disabled="loading || (page + 1) * 100 >= (report?.totals.file_count ?? 0)" @click="page++">下一页</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.change-path { overflow-wrap: anywhere; min-width: 180px; }
|
||||
.totals { white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.change-table td:not(:first-child) { white-space: nowrap; }
|
||||
</style>
|
||||
Reference in new issue
Block a user