Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(ui): show the lower-priority reason on findings and perf queue rows (#2989)

Raghav Chamadiyaf2bb62234299
diff --git a/packages/types/src/files.ts b/packages/types/src/files.ts
index fec9613f5..7e6128d00 100644
--- a/packages/types/src/files.ts
+++ b/packages/types/src/files.ts
@@ -38,6 +38,7 @@ export interface FileHealthFinding {
dimension?: HealthDimension;
/** `"unverified"` for a provisional finding type; null for a validated one. */
verification?: string | null;
+ lower_priority?: string | null;
}
export interface FileHealthMetric {
diff --git a/packages/ui/__tests__/health/lower-priority-tag.test.tsx b/packages/ui/__tests__/health/lower-priority-tag.test.tsx
new file mode 100644
index 000000000..531cc3133
--- /dev/null
+++ b/packages/ui/__tests__/health/lower-priority-tag.test.tsx
@@ -0,0 +1,37 @@
+import { render, screen } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+
+import { LowerPriorityTag } from "../../src/health/lower-priority-tag";
+import { PerformanceView } from "../../src/health/performance-view";
+import { adapter, opportunity, page } from "./fixtures/performance";
+
+describe("LowerPriorityTag", () => {
+ it("shows the reason once, without doubling the prefix", () => {
+ render(<LowerPriorityTag reason="lower priority: long, but its control flow is simple" />);
+ expect(screen.getByText(/Lower priority: long, but its control flow is simple/)).toBeTruthy();
+ });
+
+ it("shows a bare reason under the prefix", () => {
+ render(<LowerPriorityTag reason="near the bar" />);
+ expect(screen.getByText(/Lower priority: near the bar/)).toBeTruthy();
+ });
+
+ it.each([undefined, null, "", " "])("renders nothing for %p", (reason) => {
+ const { container } = render(<LowerPriorityTag reason={reason} />);
+ expect(container.firstChild).toBeNull();
+ });
+});
+
+describe("performance queue row", () => {
+ it("labels a demoted opportunity and leaves the rest unlabelled", async () => {
+ const demoted = opportunity({ lower_priority: "lower priority: where this code runs is unknown" });
+ render(<PerformanceView adapter={adapter({ getPerformanceOpportunities: async () => page({ items: [demoted] }) })} />);
+ expect(await screen.findByText(/where this code runs is unknown/)).toBeTruthy();
+ });
+
+ it("renders no label when the server does not send one", async () => {
+ render(<PerformanceView adapter={adapter()} />);
+ await screen.findAllByRole("listitem");
+ expect(document.querySelector("[data-lower-priority]")).toBeNull();
+ });
+});
diff --git a/packages/ui/__tests__/health/refactoring-card.test.tsx b/packages/ui/__tests__/health/refactoring-card.test.tsx
index dfd5c328b..6854a08c8 100644
--- a/packages/ui/__tests__/health/refactoring-card.test.tsx
+++ b/packages/ui/__tests__/health/refactoring-card.test.tsx
@@ -47,6 +47,21 @@ function findings(): RefactoringTargetFinding[] {
];
}
+describe("RefactoringCard lower priority", () => {
+ it("labels a demoted finding and leaves the others unlabelled", () => {
+ const [a, b] = findings();
+ render(
+ <RefactoringCard
+ target={target({
+ all_findings: [{ ...a!, lower_priority: "lower priority: near the bar" }, b!],
+ })}
+ />,
+ );
+ fireEvent.click(screen.getByRole("button", { name: /Show all 3 findings/ }));
+ expect(screen.getAllByText(/Lower priority: near the bar/)).toHaveLength(1);
+ });
+});
+
describe("RefactoringCard lazy findings", () => {
it("offers the expander from finding_count, without the findings themselves", () => {
// The list response no longer ships `all_findings`; the expander must not
diff --git a/packages/ui/src/files/file-health-tab.tsx b/packages/ui/src/files/file-health-tab.tsx
index 981f0564d..652d37d07 100644
--- a/packages/ui/src/files/file-health-tab.tsx
+++ b/packages/ui/src/files/file-health-tab.tsx
@@ -22,6 +22,7 @@ import { FindingOpportunityLink } from "../health/file-opportunity";
import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
import { SeverityMark } from "../health/severity-mark";
import { VerificationTag } from "../health/verification-tag";
+import { LowerPriorityTag } from "../health/lower-priority-tag";
import { formatNumber } from "../lib/format";
import type { FileDetailHealth, FunctionBlameRow } from "@repowise-dev/types/files";
import type { RefactoringOpportunity } from "@repowise-dev/types/refactoring";
@@ -247,6 +248,7 @@ export function FileHealthTab({
{biomarkerLabel(f.biomarker_type)}
</span>
<VerificationTag verification={f.verification} />
+ <LowerPriorityTag reason={f.lower_priority} />
{/* Category and pillar are machine-produced labels, so they
are mono micro-labels rather than two tinted chips —
rule 9, nothing here responds to a click. */}
diff --git a/packages/ui/src/health/health-file-drawer.tsx b/packages/ui/src/health/health-file-drawer.tsx
index 68048614b..7a3563306 100644
--- a/packages/ui/src/health/health-file-drawer.tsx
+++ b/packages/ui/src/health/health-file-drawer.tsx
@@ -51,6 +51,7 @@ import type {
import type { RefactoringOpportunity } from "@repowise-dev/types/refactoring";
import { SeverityMark } from "./severity-mark";
import { VerificationTag } from "./verification-tag";
+import { LowerPriorityTag } from "./lower-priority-tag";
import { ImpactFigure } from "./impact-figure";
export interface HealthDrawerFinding {
@@ -68,6 +69,7 @@ export interface HealthDrawerFinding {
dimension?: BiomarkerDimension | string;
/** `"unverified"` for a provisional finding type. */
verification?: string | null;
+ lower_priority?: string | null;
}
export interface HealthDrawerMetric {
@@ -232,6 +234,7 @@ export function HealthFileDrawer({
{CATEGORY_LABEL[info.category]}
</span>
<VerificationTag verification={f.verification} />
+ <LowerPriorityTag reason={f.lower_priority} />
{(() => {
// A history marker wears a neutral "Watch" chip instead of its
// pillar's: it is scored, but nothing in this file will clear it.
diff --git a/packages/ui/src/health/lower-priority-tag.tsx b/packages/ui/src/health/lower-priority-tag.tsx
new file mode 100644
index 000000000..31d97800a
--- /dev/null
+++ b/packages/ui/src/health/lower-priority-tag.tsx
@@ -0,0 +1,21 @@
+/**
+ * The honest label on an item the server demoted instead of dropping.
+ *
+ * The server sends the whole reason ("lower priority: long, but its control
+ * flow is simple"); this shows it muted so a demoted row never reads as a
+ * must-do. Renders nothing when the field is absent or null, which covers an
+ * older server.
+ */
+export function LowerPriorityTag({ reason }: { reason?: string | null | undefined }) {
+ const text = reason?.trim().replace(/^lower priority:\s*/i, "").trim();
+ if (!text) return null;
+ return (
+ <span
+ data-lower-priority
+ className="text-xs text-[var(--color-text-tertiary)]"
+ title="Listed after the rest because this can wait. It is still true."
+ >
+ Lower priority: {text} (listed after the rest)
+ </span>
+ );
+}
diff --git a/packages/ui/src/health/performance/drawer.tsx b/packages/ui/src/health/performance/drawer.tsx
index 7f4768b70..a0bce87d8 100644
--- a/packages/ui/src/health/performance/drawer.tsx
+++ b/packages/ui/src/health/performance/drawer.tsx
@@ -21,6 +21,7 @@ import { ValidationSummary } from "../../refactoring/validation-summary";
import { EFFORT_LABEL, WORK_UNIT_LABEL } from "../labels";
import { RelatedWork, useRelatedWork } from "../related-work";
import type { PerformanceViewAdapter } from "./adapter";
+import { LowerPriorityTag } from "../lower-priority-tag";
import { RawObservations } from "./evidence";
import {
ACTIONABILITY_LABEL,
@@ -294,6 +295,11 @@ function PlanSection({
return (
<Section title="Plan">
<p className="text-sm font-medium text-[var(--color-text-primary)]">{presentation.label}</p>
+ {opportunity.lower_priority ? (
+ <p className="mt-1">
+ <LowerPriorityTag reason={opportunity.lower_priority} />
+ </p>
+ ) : null}
<p className="mt-1 text-sm text-[var(--color-text-tertiary)]">{presentation.detail}</p>
{opportunity.fix ? (
<p className="mt-2 text-sm text-[var(--color-text-secondary)]">
diff --git a/packages/ui/src/health/performance/queue.tsx b/packages/ui/src/health/performance/queue.tsx
index 7c58971aa..50c019cf7 100644
--- a/packages/ui/src/health/performance/queue.tsx
+++ b/packages/ui/src/health/performance/queue.tsx
@@ -12,6 +12,7 @@ import type {
import { Button } from "../../ui/button";
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover";
import { CLICKABLE_ROW_CLS, clickableRowProps } from "../../shared/responsive-table";
+import { LowerPriorityTag } from "../lower-priority-tag";
import type { PerformanceViewAdapter } from "./adapter";
import {
ACTIONABILITY_HINT,
@@ -184,6 +185,11 @@ const OpportunityRow = memo(function OpportunityRow({
<span className="tabular-nums">{affectedSummary(opportunity)}</span> ·{" "}
{CONFIDENCE_LABEL[opportunity.confidence]} evidence confidence
</p>
+ {opportunity.lower_priority ? (
+ <p className="mt-1">
+ <LowerPriorityTag reason={opportunity.lower_priority} />
+ </p>
+ ) : null}
{why.length > 0 ? (
<p
className="mt-1 text-xs text-[var(--color-text-tertiary)]"
diff --git a/packages/ui/src/health/refactoring-card.tsx b/packages/ui/src/health/refactoring-card.tsx
index d4754b1a1..224f632a0 100644
--- a/packages/ui/src/health/refactoring-card.tsx
+++ b/packages/ui/src/health/refactoring-card.tsx
@@ -18,6 +18,7 @@ import type { RefactoringOpportunity } from "@repowise-dev/types/refactoring";
import { AskAboutThis } from "../chat/ask-about-this";
import { SeverityMark } from "./severity-mark";
import { VerificationTag } from "./verification-tag";
+import { LowerPriorityTag } from "./lower-priority-tag";
export type EffortBucket = "S" | "M" | "L" | "XL";
@@ -34,6 +35,7 @@ export interface HealthWorkItemFinding {
details?: BiomarkerDetailsRecord | null;
/** `"unverified"` for a provisional finding type. */
verification?: string | null;
+ lower_priority?: string | null;
}
export interface HealthWorkItem {
@@ -318,6 +320,7 @@ export function HealthWorkItemCard({
{biomarkerLabel(f.biomarker_type)}
</span>
<VerificationTag verification={f.verification} />
+ <LowerPriorityTag reason={f.lower_priority} />
{f.function_name ? (
<span className="text-xs font-mono text-[var(--color-text-tertiary)]">{f.function_name}</span>
) : null}