feat(advisor-comparison): add 相比上次运行 panel to report detail page

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
wangwei
2026-07-02 17:03:02 +08:00
co-authored by Copilot
parent f4016a1f09
commit 465845b2a1
3 changed files with 85 additions and 0 deletions
+18
View File
@@ -270,6 +270,24 @@ table.history-table td { font-variant-numeric: tabular-nums; }
.hist-delta.delta-bad { color: #dc2626; }
.hist-delta.delta-flat { color: var(--slate-light); }
.advisor-comparison-panel { border-left: 3px solid #0ea5e9; }
.advisor-comparison-header {
display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
margin-bottom: 10px;
}
.advisor-comparison-row {
display: flex; align-items: center; gap: 10px;
padding: 6px 0; border-bottom: 1px solid var(--line);
font-size: 13px;
}
.advisor-comparison-row:last-of-type { border-bottom: none; }
.advisor-comparison-status { font-weight: 600; white-space: nowrap; }
.advisor-comparison-metric { flex: 1; color: var(--slate); }
.advisor-comparison-scores { font-variant-numeric: tabular-nums; white-space: nowrap; }
.advisor-comparison-status.delta-good { color: #16a34a; }
.advisor-comparison-status.delta-bad { color: #dc2626; }
.advisor-comparison-status.delta-flat { color: var(--slate); }
.empty { text-align: center; padding: 60px 20px; color: var(--slate); }
.empty p { margin-bottom: 8px; }
+11
View File
@@ -174,6 +174,17 @@
<div class="section-label">④ 最低分样本(点击展开逐条复核)</div>
<div class="lowest-table" id="lowest-table"></div>
<!-- 相比上次运行(同 scenario_name 的顾问诊断对比,自动匹配,找不到则不显示) -->
<div id="advisor-comparison-section" hidden>
<div class="panel advisor-comparison-panel">
<div class="advisor-comparison-header">
<span class="section-label tight">相比上次运行</span>
<span class="muted tiny" id="advisor-comparison-meta"></span>
</div>
<div id="advisor-comparison-body"></div>
</div>
</div>
<!-- ⑤ 优化建议(optimization_advisor: true 时显示) -->
<div id="advice-section" hidden>
<div class="section-label">⑤ 优化建议 OPTIMIZATION ADVICE</div>
+56
View File
@@ -31,6 +31,7 @@ const Report = {
Report.renderDistribution(detail.report);
Report.renderGroupings(detail.report);
Report.renderLowest(detail.report);
Report.renderAdvisorComparison(detail.report);
Report.renderAdvice(detail.summary, detail.report);
Report.renderTokenUsage(detail.report);
content.style.opacity = "1";
@@ -275,6 +276,61 @@ const Report = {
wrap.innerHTML = `<table class="group-table">${head}${body}</table>`;
},
// 相比上次运行的顾问诊断对比(同 scenario_name 的最近一次前序运行,自动匹配)。
renderAdvisorComparison(report) {
const section = document.getElementById("advisor-comparison-section");
const meta = document.getElementById("advisor-comparison-meta");
const body = document.getElementById("advisor-comparison-body");
if (!section || !meta || !body) return;
const comparison = report.advisor_comparison;
if (!comparison || !comparison.entries || comparison.entries.length === 0) {
section.hidden = true;
return;
}
section.hidden = false;
meta.textContent = `对比:${comparison.previous_run_id}${App.shortTime(comparison.previous_finished_at)}`;
const STATUS_LABEL = {
resolved: "✅ 已改善",
regressed: "⚠️ 新触发",
still_triggered: "❌ 仍未解决",
new_metric: "🆕 新增指标",
};
const STATUS_CLASS = {
resolved: "delta-good",
regressed: "delta-bad",
still_triggered: "delta-bad",
new_metric: "delta-flat",
};
const fmt = (v) => (v === null || v === undefined ? "—" : Number(v).toFixed(2));
let rows = "";
comparison.entries.forEach((entry) => {
const label = STATUS_LABEL[entry.status] || entry.status;
const cls = STATUS_CLASS[entry.status] || "delta-flat";
const d = MetricPresenter.deltaInfo(entry.metric, entry.current_score, entry.previous_score);
const deltaHtml = d.hasData && d.delta !== 0
? ` <span class="hist-delta ${d.cls}">${d.arrow}${d.magnitude}</span>`
: "";
rows += `
<div class="advisor-comparison-row">
<span class="advisor-comparison-status ${cls}">${label}</span>
<span class="advisor-comparison-metric">${App.escape(App.shortMetric(entry.metric))}</span>
<span class="advisor-comparison-scores">${fmt(entry.previous_score)}${fmt(entry.current_score)}${deltaHtml}</span>
</div>`;
});
let caveat = "";
if (comparison.judge_model_changed) {
caveat = `<p class="muted tiny">⚠️ judge_model 不同(${App.escape(comparison.previous_judge_model)}${App.escape(comparison.current_judge_model)}),对比仅供参考。</p>`;
}
body.innerHTML = rows + caveat;
},
// ④ 最低分样本逐条复核表(点击展开)。
renderLowest(report) { const wrap = document.getElementById("lowest-table");
const samples = report.lowest_samples || [];