Skip to content

Commit f4f524f

Browse files
MDA2AVclaude
andcommitted
Improve probe summary: multi-segment bar with pass/warn, show totals
Bar now shows green for passed tests and amber for warnings side by side. Score displays warnings count alongside pass/scored. Legend and total test count shown below the bars. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ccbfc51 commit f4f524f

1 file changed

Lines changed: 33 additions & 12 deletions

File tree

docs/static/probe/render.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,33 +196,54 @@ window.ProbeRender = (function () {
196196
var pb = sb.passed / (sb.scored || sb.total || 1);
197197
return pb - pa || a.name.localeCompare(b.name);
198198
});
199-
var maxScored = sorted[0] ? (sorted[0].summary.scored || sorted[0].summary.total) : 1;
200-
var topPassed = sorted[0] ? (sorted[0].summary.passed || 1) : 1;
201199

202-
var html = '<div style="display:flex;flex-direction:column;gap:6px;max-width:700px;">';
200+
// Bar width is relative to total tests (not top scorer)
201+
var maxTotal = sorted[0] ? sorted[0].summary.total : 1;
202+
203+
var html = '<div style="display:flex;flex-direction:column;gap:6px;max-width:780px;">';
203204
sorted.forEach(function (sv, i) {
204205
var s = sv.summary;
205-
var scored = s.scored || s.total || 1;
206-
var pct = s.passed / scored;
207-
var barPct = (s.passed / topPassed) * 100;
208-
var displayPct = Math.round(pct * 100);
209-
var bg = pct >= 0.85 ? '#1a7f37' : pct >= 0.6 ? '#9a6700' : pct >= 0.2 ? '#cf222e' : '#82071e';
206+
var total = s.total || 1;
207+
var scored = s.scored || total;
208+
var warnings = s.warnings || 0;
209+
var passPct = (s.passed / total) * 100;
210+
var warnPct = (warnings / total) * 100;
211+
var displayPct = Math.round((s.passed / scored) * 100);
210212
var rank = i + 1;
211213

212214
html += '<div style="display:flex;align-items:center;gap:10px;">';
213215
html += '<div style="min-width:24px;text-align:right;font-size:13px;font-weight:600;color:#656d76;">' + rank + '</div>';
214216
html += '<div style="min-width:110px;font-size:13px;font-weight:600;white-space:nowrap;">' + sv.name + '</div>';
215217
var trackBg = document.documentElement.classList.contains('dark') ? '#2a2f38' : '#f0f0f0';
216-
html += '<div style="flex:1;height:22px;background:' + trackBg + ';border-radius:3px;overflow:hidden;position:relative;">';
217-
html += '<div style="height:100%;width:' + barPct + '%;background:' + bg + ';border-radius:3px;transition:width 0.3s;"></div>';
218+
html += '<div style="flex:1;height:22px;background:' + trackBg + ';border-radius:3px;overflow:hidden;position:relative;display:flex;">';
219+
html += '<div style="height:100%;width:' + passPct + '%;background:' + PASS_BG + ';transition:width 0.3s;"></div>';
220+
if (warnings > 0) {
221+
html += '<div style="height:100%;width:' + warnPct + '%;background:' + WARN_BG + ';transition:width 0.3s;"></div>';
222+
}
223+
html += '</div>';
224+
html += '<div style="min-width:120px;text-align:right;font-size:13px;font-weight:700;">'
225+
+ s.passed + '/' + scored;
226+
if (warnings > 0) {
227+
html += ' <span style="font-weight:400;color:#656d76;font-size:12px;">' + warnings + 'w</span>';
228+
}
218229
html += '</div>';
219-
html += '<div style="min-width:72px;text-align:right;font-size:13px;font-weight:700;">' + s.passed + '/' + scored + '</div>';
220230
html += '<div style="min-width:40px;text-align:right;font-size:12px;color:#656d76;">' + displayPct + '%</div>';
221231
html += '</div>';
222232
});
223233
html += '</div>';
234+
235+
// Legend + total
236+
var totalTests = sorted[0] ? sorted[0].summary.total : 0;
237+
html += '<div style="display:flex;align-items:center;gap:16px;margin-top:10px;font-size:12px;color:#656d76;">';
238+
html += '<span>' + totalTests + ' tests total</span>';
239+
html += '<span style="display:inline-flex;align-items:center;gap:4px;"><span style="display:inline-block;width:10px;height:10px;border-radius:2px;background:' + PASS_BG + ';"></span> Pass</span>';
240+
html += '<span style="display:inline-flex;align-items:center;gap:4px;"><span style="display:inline-block;width:10px;height:10px;border-radius:2px;background:' + WARN_BG + ';"></span> Warn</span>';
241+
var failBg = document.documentElement.classList.contains('dark') ? '#2a2f38' : '#f0f0f0';
242+
html += '<span style="display:inline-flex;align-items:center;gap:4px;"><span style="display:inline-block;width:10px;height:10px;border-radius:2px;background:' + failBg + ';border:1px solid #656d76;"></span> Fail</span>';
243+
html += '</div>';
244+
224245
if (data.commit) {
225-
html += '<p style="margin-top:12px;font-size:0.85em;color:#656d76;">Commit: <code>' + data.commit.id.substring(0, 7) + '</code> &mdash; ' + (data.commit.message || '') + '</p>';
246+
html += '<p style="margin-top:8px;font-size:0.85em;color:#656d76;">Commit: <code>' + data.commit.id.substring(0, 7) + '</code> &mdash; ' + (data.commit.message || '') + '</p>';
226247
}
227248
el.innerHTML = html;
228249
}

0 commit comments

Comments
 (0)