feat(advisor-comparison): add 相比上次运行 panel to report detail page
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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 || [];
|
||||
|
||||
Reference in New Issue
Block a user