Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: rank severity-sorted groups by tier precedence, not weighted sum (#1600)

[._.]/ Adam Eivye7c56245fc4c
diff --git a/client/src/lib/editorialChecks.js b/client/src/lib/editorialChecks.js
index 7e9ad917dc..0bf31198f2 100644
--- a/client/src/lib/editorialChecks.js
+++ b/client/src/lib/editorialChecks.js
@@ -226,9 +226,15 @@ function sortComments(comments, sort) {
// from its already-sorted comments (e.g. its lowest issue number / best status).
function sortGroups(groups, sort) {
if (sort === 'severity') {
- // Surface the checks with the most severe open findings first.
- const weight = (g) => g.counts.high * 100 + g.counts.medium * 10 + g.counts.low;
- return [...groups].sort((a, b) => weight(b) - weight(a) || b.open - a.open);
+ // Surface the checks with the most severe open findings first. Compare tiers
+ // lexicographically (high, then medium, then low) so a single high finding
+ // always outranks any volume of lower-severity ones — a weighted sum would
+ // let 101 lows bury a high.
+ return [...groups].sort((a, b) =>
+ (b.counts.high - a.counts.high)
+ || (b.counts.medium - a.counts.medium)
+ || (b.counts.low - a.counts.low)
+ || (b.open - a.open));
}
if (sort === 'issue') {
const leadIssue = (g) => {
diff --git a/client/src/lib/editorialChecks.test.js b/client/src/lib/editorialChecks.test.js
index 97ad7133e8..d39653cabc 100644
--- a/client/src/lib/editorialChecks.test.js
+++ b/client/src/lib/editorialChecks.test.js
@@ -203,6 +203,17 @@ describe('applyFindingsView', () => {
expect(view.map((g) => g.checkId)).toEqual(['pacing', 'naming']);
});
+ it('ranks a single high-severity group above a noisy many-low group when sort=severity', () => {
+ const comments = [
+ { id: 'h1', checkId: 'one-high', status: 'open', severity: 'high', problem: 'Critical' },
+ ...Array.from({ length: 50 }, (_, i) => (
+ { id: `l${i}`, checkId: 'many-low', status: 'open', severity: 'low', problem: `Nit ${i}` })),
+ ];
+ const rows = { 'one-high': { label: 'One high', scope: 'series' }, 'many-low': { label: 'Many low', scope: 'series' } };
+ const view = applyFindingsView(groupFindingsByCheck(comments, rows), {}, 'severity');
+ expect(view.map((g) => g.checkId)).toEqual(['one-high', 'many-low']);
+ });
+
it('sorts findings by issue number with series-wide last when sort=issue', () => {
const view = applyFindingsView(groupsFixture(), { checkIds: new Set(['naming']) }, 'issue');
expect(view[0].comments.map((c) => c.id)).toEqual(['b1', 'b2']); // issue 1 before series-wide