fix(shipping-process-gates): 收口技术重试并补齐运维 UI

跨 Job 累计技术失败次数,耗尽后将 Attempt/Gate 置为 failed_terminal;
收缩旧 action_buttons;healthcheck 增加 Worker 领取探针;恢复卡展示责任方与审计,Admin 诊断改主从布局。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-01 13:54:14 +08:00
1 parent 323928626b
commit cef3d5b26a
15 files changed
+489 -150

No files matched your search

@@ -2,7 +2,8 @@
features/admin/modules/shipping-process-gates/ShippingProcessGateDiagnosticsPage.vue
用途:管理员 Process Gate Execution 诊断——列表、Gate 轨道与 Attempt 明细。
依赖:process-gates.api、Vue Router、Vue I18n(admin + workspace.processGate 动作文案)。
逻辑:只读诊断;多维度筛选(status/gate/reason/party/q/时间);小屏卡片化列表,lg+ 横向表格(nowrap + 滚动提示);
逻辑:只读诊断;多维度筛选(status/gate/reason/party/q/时间);小屏卡片列表 + 详情下置;
lg+ 主从布局(左侧 ~38% Execution 紧凑列表 + 分页,右侧 sticky 详情:Gate/findings/attempts);
状态/动作展示业务标签并附技术码;Gate 诊断结构化卡片(findings/blocking/effective_result);
Attempt 展示 snapshot_diff 摘要并可跳转 AdminShippingAudit。
-->
@@ -393,6 +394,13 @@ async function loadAttempts(gateCode: string) {
}
}
/**
* 判断 Execution 是否为当前详情选中项,供 lg+ 主从列表行高亮。
*/
function isExecutionSelected(executionNo: string): boolean {
return Boolean(detail.value?.execution_no && detail.value.execution_no === executionNo);
}
/**
* 关闭详情面板。
*/
@@ -531,63 +539,56 @@ onMounted(() => {
</article>
</div>
<!-- lg+:横向表格;表头 nowrap + 外层滚动 -->
<div class="hidden lg:block">
<p class="mb-2 text-xs text-muted">{{ t('admin.shippingProcessGates.scrollHint') }}</p>
<div class="overflow-x-auto rounded-xl border border-default">
<table class="min-w-[720px] w-full text-sm">
<thead class="bg-surface-soft text-left text-xs uppercase text-muted">
<tr>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.executionNo') }}</th>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.status') }}</th>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.currentGate') }}</th>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.nextAction') }}</th>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.updatedAt') }}</th>
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-if="loading">
<td colspan="6" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingProcessGates.loading') }}</td>
</tr>
<tr v-else-if="!rows.length">
<td colspan="6" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingProcessGates.empty') }}</td>
</tr>
<tr v-for="row in rows" :key="row.execution_no" class="border-t border-default">
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs">{{ row.execution_no }}</td>
<td class="px-4 py-3">
<div>{{ statusLabel(row.status) }}</div>
<div class="font-mono text-[11px] text-muted">{{ row.status }}</div>
</td>
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs">{{ row.current_gate_code || '—' }}</td>
<td class="px-4 py-3 text-xs">{{ actionLabel(row.primary_next_action_code) }}</td>
<td class="whitespace-nowrap px-4 py-3">{{ formatTime(row.updated_at) }}</td>
<td class="whitespace-nowrap px-4 py-3">
<button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.execution_no)">
{{ t('admin.shippingProcessGates.viewDetail') }}
</button>
</td>
</tr>
</tbody>
</table>
<!-- lg+ 主从:左列表+分页,右 sticky 详情;小屏在网格外卡片列表,网格内仅分页+详情 -->
<div class="grid lg:grid-cols-[minmax(280px,38%)_minmax(0,1fr)] gap-4 items-start">
<div class="space-y-3">
<!-- lg+:紧凑 Execution 行列表 -->
<div class="hidden lg:block space-y-1.5" data-testid="shipping-process-gate-list">
<p v-if="loading" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
{{ t('admin.shippingProcessGates.loading') }}
</p>
<p v-else-if="!rows.length" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
{{ t('admin.shippingProcessGates.empty') }}
</p>
<button
v-for="row in rows"
:key="row.execution_no"
type="button"
class="w-full rounded-lg border px-3 py-2.5 text-left text-sm transition-colors"
:class="isExecutionSelected(row.execution_no)
? 'border-brand-500 bg-brand-50/80 ring-1 ring-brand-500/40 dark:bg-brand-950/30'
: 'border-default bg-surface hover:bg-surface-soft'"
@click="openDetail(row.execution_no)"
>
<div class="font-mono text-xs break-all">{{ row.execution_no }}</div>
<div class="mt-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs">
<span>{{ statusLabel(row.status) }}</span>
<span class="font-mono text-[11px] text-muted">{{ row.status }}</span>
</div>
<div class="mt-1 truncate font-mono text-[11px] text-muted">
{{ row.current_gate_code || '—' }}
</div>
<div class="mt-1 truncate text-[11px] text-muted">{{ actionLabel(row.primary_next_action_code) }}</div>
<div class="mt-1 text-[11px] text-muted">{{ formatTime(row.updated_at) }}</div>
</button>
</div>
<div class="flex items-center gap-2 text-sm">
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">
{{ t('admin.shippingProcessGates.previous') }}
</button>
<span>{{ page }}</span>
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
{{ t('admin.shippingProcessGates.next') }}
</button>
</div>
</div>
</div>
<div class="flex items-center gap-2 text-sm">
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">
{{ t('admin.shippingProcessGates.previous') }}
</button>
<span>{{ page }}</span>
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
{{ t('admin.shippingProcessGates.next') }}
</button>
</div>
<aside
v-if="detail"
class="rounded-xl border border-default bg-surface p-4"
data-testid="shipping-process-gate-detail"
>
<aside
v-if="detail"
class="rounded-xl border border-default bg-surface p-4 lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto"
data-testid="shipping-process-gate-detail"
>
<div class="mb-4 flex items-center justify-between gap-2">
<h2 class="text-lg font-semibold">{{ t('admin.shippingProcessGates.detailTitle') }}</h2>
<button type="button" class="text-sm text-muted hover:text-primary" @click="closeDetail">{{ t('admin.close') }}</button>
@@ -789,6 +790,7 @@ onMounted(() => {
</div>
<p v-else class="mt-2 text-sm text-muted">{{ t('admin.shippingProcessGates.noAttempts') }}</p>
</template>
</aside>
</aside>
</div>
</div>
</template>
@@ -33,6 +33,7 @@ describe('ProcessGateRecoveryCard', () => {
},
blocking_message: 'HTTP 500 error: node_id=abc',
diagnostic_hint: 'traceback: C:\\service\\worker.py',
responsible_party: 'owner',
};
const wrapper = mount(ProcessGateRecoveryCard, {
props: { summary, canHandle: true },
@@ -43,6 +44,9 @@ describe('ProcessGateRecoveryCard', () => {
expect(text).toContain('当前步骤');
expect(text).toContain('继续处理');
expect(text).toContain('当前步骤需要人工处理');
expect(text).toContain('责任方');
expect(text).toContain('订单复核 / 任务负责人');
expect(text).toContain('查看审计');
for (const technicalText of [
'auto_build_gate_quality_gate_passed', 'quality_gate_internal', 'internal_reason_code',
'internal_retry_action', 'HTTP 500', 'node_id', 'traceback', 'worker.py',
@@ -1,15 +1,17 @@
/**
* features/shipping-process-gates/components/ProcessGateRecoveryCard.vue
* 用途:任务工作台展示当前待处理环节与服务端下发的主要处理按钮。
* 依赖:useShippingProcessGateRecovery、processGateNavigation、ShippingProcessGateUserSummary。
* 用途:任务工作台展示当前待处理环节、责任方、主恢复动作与 Gate 审计入口。
* 依赖:useShippingProcessGateRecovery、processGateNavigation、process-gates.api、
* ShippingProcessGateUserSummary。
* 逻辑:导航类动作 router.push;POST 类动作调 Workspace API;409 触发 refreshed;
* canHandle=false 时只读;禁止展示内部编号、原因码和技术诊断文本。
* 可展开查看审计事件;canHandle=false 时只读;禁止展示内部编号与技术诊断原文。
*/
<script setup lang="ts">
import { computed } from 'vue';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useShippingProcessGateRecovery } from '../composables/useShippingProcessGateRecovery';
import type { ProcessGateNavigationContext } from '../composables/processGateNavigation';
import { listWorkspaceProcessGateAuditEvents } from '../api/process-gates.api';
import type { ShippingProcessGateUserSummary } from '../types/process-gate.types';
const props = defineProps<{
@@ -26,6 +28,10 @@ const emit = defineEmits<{
const { t, te } = useI18n();
const { busy, submitPrimaryAction } = useShippingProcessGateRecovery();
const auditOpen = ref(false);
const auditLoading = ref(false);
const auditError = ref('');
const auditItems = ref<Array<Record<string, unknown>>>([]);
const blockingGate = computed(() => props.summary?.current_blocking_gate || null);
const nextActionCode = computed(() =>
@@ -76,6 +82,16 @@ const blockingReasonLabel = computed(() => {
const diagnosticHint = computed(() => safeBusinessText(props.summary?.diagnostic_hint));
/**
* 责任方业务标签(owner/worker/system/admin/external)。
*/
const responsiblePartyLabel = computed(() => {
const code = String(props.summary?.responsible_party || '').trim();
if (!code) return '';
const key = `workspace.shippingNotice.processGate.parties.${code}`;
return te(key) ? t(key) : code;
});
/**
* 触发恢复动作:导航 / POST;409 时通知父级刷新最新 Gate 投影。
*/
@@ -97,6 +113,35 @@ async function runPrimaryAction() {
emit('refreshed');
}
}
/**
* 展开/收起 Gate 审计列表;首次展开时拉取 Workspace 审计 API。
*/
async function toggleAudit() {
auditOpen.value = !auditOpen.value;
if (!auditOpen.value || auditItems.value.length || !props.summary?.execution_no) return;
auditLoading.value = true;
auditError.value = '';
try {
const page = await listWorkspaceProcessGateAuditEvents(props.summary.execution_no, 1, 20);
auditItems.value = Array.isArray(page.items) ? page.items as Array<Record<string, unknown>> : [];
} catch {
auditError.value = t('workspace.shippingNotice.processGate.auditLoadFailed');
auditItems.value = [];
} finally {
auditLoading.value = false;
}
}
/**
* 格式化审计事件时间。
*/
function formatAuditTime(value: unknown): string {
const text = String(value || '').trim();
if (!text) return '—';
const date = new Date(text);
return Number.isNaN(date.getTime()) ? text : date.toLocaleString();
}
</script>
<template>
@@ -116,13 +161,18 @@ async function runPrimaryAction() {
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.blockingMessage') }}</dt>
<dd class="text-secondary">{{ blockingReasonLabel }}</dd>
</div>
<div v-if="responsiblePartyLabel">
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.responsibleParty') }}</dt>
<dd class="text-secondary">{{ responsiblePartyLabel }}</dd>
</div>
<div v-if="diagnosticHint">
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.diagnosticHint') }}</dt>
<dd class="text-secondary">{{ diagnosticHint }}</dd>
</div>
</dl>
<div v-if="hasRecoveryAction" class="mt-3 flex flex-wrap items-center gap-2">
<div class="mt-3 flex flex-wrap items-center gap-2">
<button
v-if="hasRecoveryAction"
type="button"
class="rounded-xl bg-primary px-3 py-1.5 text-sm font-medium text-on-primary disabled:opacity-60"
:disabled="!canHandle || busy"
@@ -130,9 +180,30 @@ async function runPrimaryAction() {
>
{{ busy ? $t('workspace.shippingNotice.processGate.submitting') : actionLabel }}
</button>
<button
type="button"
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary hover:bg-surface-soft"
data-testid="process-gate-view-audit"
@click="toggleAudit"
>
{{ auditOpen
? $t('workspace.shippingNotice.processGate.hideAudit')
: $t('workspace.shippingNotice.processGate.viewAudit') }}
</button>
<span v-if="!canHandle" class="text-xs text-muted">
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
</span>
</div>
<div v-if="auditOpen" class="mt-3 rounded-xl border border-default bg-surface px-3 py-2 text-xs">
<p v-if="auditLoading" class="text-muted">{{ $t('workspace.shippingNotice.processGate.auditLoading') }}</p>
<p v-else-if="auditError" class="text-rose-600">{{ auditError }}</p>
<p v-else-if="!auditItems.length" class="text-muted">{{ $t('workspace.shippingNotice.processGate.auditEmpty') }}</p>
<ul v-else class="space-y-2">
<li v-for="(item, index) in auditItems" :key="String(item.id || index)" class="border-t border-default pt-2 first:border-t-0 first:pt-0">
<div class="font-medium text-secondary">{{ item.event_type || item.action || '—' }}</div>
<div class="text-muted">{{ formatAuditTime(item.created_at) }}</div>
</li>
</ul>
</div>
</section>
</template>
+13
View File
@@ -192,6 +192,19 @@
"blockingMessage": "What needs attention",
"reasonCode": "Reason",
"diagnosticHint": "Suggested action",
"responsibleParty": "Responsible party",
"viewAudit": "View audit",
"hideAudit": "Hide audit",
"auditLoading": "Loading audit…",
"auditEmpty": "No process-gate audit events",
"auditLoadFailed": "Failed to load process-gate audit",
"parties": {
"owner": "Order reviewer / task owner",
"worker": "System worker",
"system": "System automation",
"admin": "Administrator",
"external": "External system"
},
"noAction": "No action is currently available",
"versionMissing": "This information has changed. Refresh and try again.",
"navigationMissing": "Navigation context is missing. Refresh and try again.",
+13
View File
@@ -133,6 +133,19 @@
"blockingMessage": "เหตุผลที่ต้องดำเนินการ",
"reasonCode": "เหตุผล",
"diagnosticHint": "คำแนะนำในการดำเนินการ",
"responsibleParty": "ผู้รับผิดชอบ",
"viewAudit": "ดูบันทึกตรวจสอบ",
"hideAudit": "ซ่อนบันทึกตรวจสอบ",
"auditLoading": "กำลังโหลดบันทึกตรวจสอบ…",
"auditEmpty": "ยังไม่มีเหตุการณ์ตรวจสอบของเกต",
"auditLoadFailed": "โหลดบันทึกตรวจสอบของเกตไม่สำเร็จ",
"parties": {
"owner": "ผู้ตรวจทานคำสั่งซื้อ / เจ้าของงาน",
"worker": "ระบบ Worker",
"system": "ระบบอัตโนมัติ",
"admin": "ผู้ดูแลระบบ",
"external": "ระบบภายนอก"
},
"noAction": "ขณะนี้ไม่มีการดำเนินการที่ใช้ได้",
"versionMissing": "ข้อมูลนี้มีการเปลี่ยนแปลง โปรดรีเฟรชแล้วลองใหม่",
"navigationMissing": "ไม่มีข้อมูลสำหรับนำทาง โปรดรีเฟรชแล้วลองใหม่",
+13
View File
@@ -193,6 +193,19 @@
"blockingMessage": "需要处理的原因",
"reasonCode": "处理原因",
"diagnosticHint": "处理建议",
"responsibleParty": "责任方",
"viewAudit": "查看审计",
"hideAudit": "收起审计",
"auditLoading": "正在加载审计…",
"auditEmpty": "暂无门禁审计事件",
"auditLoadFailed": "加载门禁审计失败",
"parties": {
"owner": "订单复核 / 任务负责人",
"worker": "系统 Worker",
"system": "系统自动",
"admin": "管理员",
"external": "外部系统"
},
"noAction": "当前没有可执行的处理操作",
"versionMissing": "当前信息已更新,请刷新后重试",
"navigationMissing": "缺少跳转所需的任务或复核信息,请刷新后重试",
+13
View File
@@ -193,6 +193,19 @@
"blockingMessage": "需要處理的原因",
"reasonCode": "處理原因",
"diagnosticHint": "處理建議",
"responsibleParty": "責任方",
"viewAudit": "檢視審計",
"hideAudit": "收起審計",
"auditLoading": "正在載入審計…",
"auditEmpty": "暫無門禁審計事件",
"auditLoadFailed": "載入門禁審計失敗",
"parties": {
"owner": "訂單覆核 / 任務負責人",
"worker": "系統 Worker",
"system": "系統自動",
"admin": "管理員",
"external": "外部系統"
},
"noAction": "目前沒有可執行的處理操作",
"versionMissing": "目前資訊已更新,請重新整理後再試",
"navigationMissing": "缺少跳轉所需的任務或覆核資訊,請重新整理後再試",