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: order finding groups by the chosen issue/status sort, not just rows (#1600)

[._.]/ Adam Eivy69e9401b2f8a
diff --git a/client/src/lib/editorialChecks.js b/client/src/lib/editorialChecks.js
index 8dec4b1254..7e9ad917dc 100644
--- a/client/src/lib/editorialChecks.js
+++ b/client/src/lib/editorialChecks.js
@@ -221,11 +221,27 @@ function sortComments(comments, sort) {
.map(([c]) => c);
}
+// Order the groups to match the chosen sort, so a multi-check view reads as
+// sorted across groups — not just within each one. Each group's lead value comes
+// from its already-sorted comments (e.g. its lowest issue number / best status).
function sortGroups(groups, sort) {
- if (sort !== 'severity') return groups; // groups already arrive scope→label ordered
- // 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);
+ 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);
+ }
+ if (sort === 'issue') {
+ const leadIssue = (g) => {
+ const c = g.comments.find((x) => Number.isInteger(x.issueNumber));
+ return c ? c.issueNumber : Infinity; // series-wide-only groups sort last
+ };
+ return [...groups].sort((a, b) => leadIssue(a) - leadIssue(b) || a.label.localeCompare(b.label));
+ }
+ if (sort === 'status') {
+ const leadStatus = (g) => Math.min(...g.comments.map((c) => statusRank(normStatus(c))));
+ return [...groups].sort((a, b) => leadStatus(a) - leadStatus(b) || a.label.localeCompare(b.label));
+ }
+ return groups; // scope: already scope→label ordered
}
/**
diff --git a/client/src/lib/editorialChecks.test.js b/client/src/lib/editorialChecks.test.js
index bd6ed1abfc..97ad7133e8 100644
--- a/client/src/lib/editorialChecks.test.js
+++ b/client/src/lib/editorialChecks.test.js
@@ -208,6 +208,19 @@ describe('applyFindingsView', () => {
expect(view[0].comments.map((c) => c.id)).toEqual(['b1', 'b2']); // issue 1 before series-wide
});
+ it('orders GROUPS by their lowest issue number when sort=issue (not just rows)', () => {
+ // naming's lowest issue is 1; pacing's is 2 — so naming leads even though the
+ // default scope order puts scene-scoped pacing first.
+ const view = applyFindingsView(groupsFixture(), {}, 'issue');
+ expect(view.map((g) => g.checkId)).toEqual(['naming', 'pacing']);
+ });
+
+ it('orders GROUPS by best open status then label when sort=status', () => {
+ // Both groups have an open finding (rank 0) → alphabetical tiebreak: Naming, Pacing.
+ const view = applyFindingsView(groupsFixture(), {}, 'status');
+ expect(view.map((g) => g.checkId)).toEqual(['naming', 'pacing']);
+ });
+
it('combines filters (AND semantics across facets)', () => {
const view = applyFindingsView(
groupsFixture(),