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): lighter refactoring lede, collapsed drawer detail and Fix first open by default (#3300)

Raghav Chamadiyabf3af6c268b7
diff --git a/packages/ui/__tests__/health/fix-first.test.tsx b/packages/ui/__tests__/health/fix-first.test.tsx
index 07292cb97..8c5ab2f34 100644
--- a/packages/ui/__tests__/health/fix-first.test.tsx
+++ b/packages/ui/__tests__/health/fix-first.test.tsx
@@ -1,6 +1,7 @@
/**
- * Fix first renders core's queue as it arrives: the section starts closed
- * with its count, the header states the scope exactly, each row is two scan
+ * Fix first renders core's queue as it arrives: the section starts open
+ * with its count, the header states the scope exactly, exclusions sit in a
+ * popover, each row is two scan
* lines that open onto the why, steps and Verify, and actions appear only
* where the item can back them.
*/
@@ -10,7 +11,11 @@ import { fireEvent, render, screen, waitFor, within } from "@testing-library/rea
import type { FixFirstQueue, FixItem } from "@repowise-dev/types/fix-first";
import { FixFirstList } from "../../src/health/fix-first/fix-first-list";
-import { fixFirstScopeSentence, fixPlanLabel } from "../../src/health/fix-first/scope";
+import {
+ exclusionPhrase,
+ fixFirstScopeSentence,
+ fixPlanLabel,
+} from "../../src/health/fix-first/scope";
import { FIX_FIRST_QUEUE } from "./fixtures/fix-first";
const [REFACTOR, FINDING, PERF] = FIX_FIRST_QUEUE.items as [FixItem, FixItem, FixItem];
@@ -34,20 +39,32 @@ function openRow(item: FixItem) {
}
describe("Fix first header", () => {
- it("starts closed, with the title and the item count on the toggle", () => {
+ it("starts open, with the title and the item count on the toggle", () => {
const { container } = renderList();
const details = container.querySelector("details")!;
- expect(details.open).toBe(false);
+ expect(details.open).toBe(true);
const summary = container.querySelector("summary")!;
expect(summary.textContent).toContain("Fix first");
expect(summary.textContent).toContain("3 items");
});
- it("states shown of eligible and every nonzero exclusion with its count", () => {
- expect(fixFirstScopeSentence(FIX_FIRST_QUEUE)).toBe(
- "3 of 423 eligible items. Excluded: 612 in tests, 91 tooling, 5 generated, " +
- "158 expected repetition, 12 with no safe fix, 505 below the worth floor, 167 history only.",
- );
+ it("states shown of eligible, and lists every nonzero exclusion in a popover", async () => {
+ expect(fixFirstScopeSentence(FIX_FIRST_QUEUE)).toBe("3 of 423 eligible items.");
+ renderList();
+ expect(screen.queryByText("612 in tests")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "1,550 excluded" }));
+ const dialog = await screen.findByRole("dialog");
+ for (const line of [
+ "612 in tests",
+ "91 tooling",
+ "5 generated",
+ "158 expected repetition",
+ "12 with no safe fix",
+ "505 below the worth floor",
+ "167 history only",
+ ]) {
+ expect(within(dialog).getByText(line)).toBeTruthy();
+ }
});
it("counts dormant functions apart from what they excluded", () => {
@@ -59,9 +76,10 @@ describe("Fix first header", () => {
dormant: 1,
},
};
- const sentence = fixFirstScopeSentence(queue);
- expect(sentence).toContain("3 switched off by a constant flag, 2 in dead code (delete it)");
- expect(sentence).toMatch(/Dormant: 1 function behind a disabled flag\.$/);
+ expect(exclusionPhrase(queue.totals.excluded)).toContain(
+ "3 switched off by a constant flag, 2 in dead code (delete it)",
+ );
+ expect(fixFirstScopeSentence(queue)).toMatch(/Dormant: 1 function behind a disabled flag\.$/);
});
it("omits a rule that excluded nothing", () => {
@@ -72,9 +90,9 @@ describe("Fix first header", () => {
excluded: { ...FIX_FIRST_QUEUE.totals.excluded, test: 0, generated: 0 },
},
};
- const sentence = fixFirstScopeSentence(queue);
- expect(sentence).not.toContain("in tests");
- expect(sentence).not.toContain("generated");
+ const phrase = exclusionPhrase(queue.totals.excluded);
+ expect(phrase).not.toContain("in tests");
+ expect(phrase).not.toContain("generated");
});
it("asks for scope=all when tests are included, and says so", () => {
diff --git a/packages/ui/__tests__/health/performance-presentation.test.ts b/packages/ui/__tests__/health/performance-presentation.test.ts
index c12e52afa..ffe2bc5bc 100644
--- a/packages/ui/__tests__/health/performance-presentation.test.ts
+++ b/packages/ui/__tests__/health/performance-presentation.test.ts
@@ -110,6 +110,14 @@ describe("performance presentation", () => {
expect(none.label).toBe("No safe plan");
});
+ it("names a stored plan apart from the plan-ready actionability state", () => {
+ // The row mark counts with the "With a stored plan" tile; "Plan ready" is
+ // the actionability state its own tile counts.
+ expect(planPresentation(opportunity()).label).toBe("Stored plan");
+ expect(facetValueLabel("plan_state", "available")).toBe("Stored plan");
+ expect(facetValueLabel("actionability", "plan_ready")).toBe("Plan ready");
+ });
+
it("never calls a plan actionable without an id to fetch it with", () => {
expect(planPresentation(opportunity({ plan_id: null })).actionable).toBe(false);
});
diff --git a/packages/ui/__tests__/health/performance-view.test.tsx b/packages/ui/__tests__/health/performance-view.test.tsx
index dbb7a35fe..d62487239 100644
--- a/packages/ui/__tests__/health/performance-view.test.tsx
+++ b/packages/ui/__tests__/health/performance-view.test.tsx
@@ -19,6 +19,11 @@ const openFirstRow = async () => {
return first!;
};
+/** Open a collapsed drawer section by its toggle's name. */
+function expand(panel: HTMLElement, name: string | RegExp) {
+ fireEvent.click(within(panel).getByRole("button", { name }));
+}
+
describe("PerformanceView queue", () => {
it("leads with the canonical rollup rather than flat context counters", async () => {
render(<PerformanceView adapter={adapter()} />);
@@ -213,6 +218,7 @@ describe("PerformanceView drawer", () => {
render(<PerformanceView adapter={adapter()} />);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ expand(panel, "What the evidence shows");
expect(within(panel).getByText("Evidence confidence")).toBeTruthy();
expect(within(panel).getByText("Actionability confidence")).toBeTruthy();
expect(within(panel).getByText("Fix safety")).toBeTruthy();
@@ -224,6 +230,7 @@ describe("PerformanceView drawer", () => {
render(<PerformanceView adapter={adapter()} />);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ expand(panel, "What the evidence shows");
expect(within(panel).getByText("Loop magnitude")).toBeTruthy();
expect(within(panel).getByText("Grows with data")).toBeTruthy();
expect(within(panel).getByText("self._sem")).toBeTruthy();
@@ -239,12 +246,14 @@ describe("PerformanceView drawer", () => {
await openFirstRow();
await waitFor(() => expect(getDetail).toHaveBeenCalled());
const panel = await screen.findByRole("dialog");
+ expand(panel, "What the evidence shows");
expect(within(panel).queryByText("Loop magnitude")).toBeNull();
});
it("carries the exact drill-down an agent should call", async () => {
render(<PerformanceView adapter={adapter()} />);
await openFirstRow();
+ expand(await screen.findByRole("dialog"), "Hand this to an agent");
expect(await screen.findByText('get_health(opportunity_id="perf2_planready")')).toBeTruthy();
});
@@ -256,7 +265,8 @@ describe("PerformanceView drawer", () => {
expect(getDetail).toHaveBeenCalledWith("perf2_planready", { evidenceLimit: 8 }),
);
const panel = await screen.findByRole("dialog");
- expect(within(panel).getByText(/Analyzed at/)).toBeTruthy();
+ expand(panel, "Hand this to an agent");
+ expect(await within(panel).findByText(/Analyzed at/)).toBeTruthy();
});
it("says a cause is no longer observed instead of showing it as open", async () => {
@@ -616,6 +626,7 @@ describe("PerformanceView drawer plan steps and validation", () => {
);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ expand(panel, /^Tests/);
expect(within(panel).getByText(/Measured coverage/)).toBeTruthy();
expect(within(panel).getByText(/via call graph/)).toBeTruthy();
expect(within(panel).getByText("tests/test_a.py")).toBeTruthy();
@@ -643,6 +654,7 @@ describe("PerformanceView drawer plan steps and validation", () => {
);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ expand(panel, /^Tests/);
expect(within(panel).getByText(/via name match/)).toBeTruthy();
});
@@ -662,6 +674,10 @@ describe("PerformanceView drawer plan steps and validation", () => {
);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ // No guarding test is the case a reader needs, so the section opens on it.
+ const tests = within(panel).getByRole("button", { name: /^Tests/ });
+ expect(tests.getAttribute("aria-expanded")).toBe("true");
+ expect(tests.textContent).toContain("none guarding");
expect(within(panel).getByText("Validation gap")).toBeTruthy();
expect(within(panel).getByText(/Treat this as explicit validation work/)).toBeTruthy();
});
@@ -671,6 +687,7 @@ describe("PerformanceView drawer plan steps and validation", () => {
await openFirstRow();
const panel = await screen.findByRole("dialog");
expect(within(panel).queryByText(/guarding test/)).toBeNull();
+ expect(within(panel).queryByRole("button", { name: /^Tests/ })).toBeNull();
expect(within(panel).queryByText(/Validation gap/)).toBeNull();
});
});
@@ -886,6 +903,7 @@ describe("PerformanceView drawer, the fix itself", () => {
render(<PerformanceView adapter={adapter()} />);
await openFirstRow();
const panel = await screen.findByRole("dialog");
+ expand(panel, "What the evidence shows");
for (const facet of ["amplification", "exposure", "leverage", "change risk", "loop magnitude"]) {
expect(within(panel).getByRole("button", { name: `What ${facet} means` })).toBeTruthy();
}
@@ -894,7 +912,7 @@ describe("PerformanceView drawer, the fix itself", () => {
it("widens the excerpt up to the loop header and names the sink once", async () => {
const lines = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`);
lines[5] = " for row in rows:";
- const readSource = vi.fn(async () => lines.join(String.fromCharCode(10)));
+ const readSource = vi.fn(async () => lines.join("\n"));
render(<PerformanceView adapter={adapter({ readSource })} />);
await openFirstRow();
const panel = await screen.findByRole("dialog");
@@ -908,7 +926,7 @@ describe("PerformanceView drawer, the fix itself", () => {
it("says so when no loop header sits within reach of the call", async () => {
const lines = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`);
- const readSource = vi.fn(async () => lines.join(String.fromCharCode(10)));
+ const readSource = vi.fn(async () => lines.join("\n"));
render(<PerformanceView adapter={adapter({ readSource })} />);
await openFirstRow();
const panel = await screen.findByRole("dialog");
diff --git a/packages/ui/__tests__/refactoring/opportunity-drawer.test.tsx b/packages/ui/__tests__/refactoring/opportunity-drawer.test.tsx
index 050199557..7e0fee4db 100644
--- a/packages/ui/__tests__/refactoring/opportunity-drawer.test.tsx
+++ b/packages/ui/__tests__/refactoring/opportunity-drawer.test.tsx
@@ -10,11 +10,13 @@ import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import type {
OpportunityStep,
+ RecommendationValidation,
RefactoringOpportunityDetailResolved,
RefactoringPlan,
} from "@repowise-dev/types/refactoring";
import { OpportunityDrawer } from "../../src/refactoring/opportunity-drawer";
+import { RefactoringDrawer } from "../../src/refactoring/refactoring-drawer";
function detail(
overrides: Partial<RefactoringOpportunityDetailResolved> = {},
@@ -122,22 +124,59 @@ const PLAN = {
describe("OpportunityDrawer reach, verification and code", () => {
it("states the blast radius for every type, importers included when stored", () => {
renderDrawer(detail({ affected_files_total: 2, dependents: 4 }));
- expect(screen.getByText("Touches 2 files; 4 files import it.")).toBeTruthy();
+ expect(screen.getByText(/^Touches 2 files; 4 files import it\./)).toBeTruthy();
});
it("says when importers were not recorded instead of implying none", () => {
renderDrawer(detail());
- expect(screen.getByText("Touches 1 file; importers not recorded.")).toBeTruthy();
+ expect(
+ screen.getByText("Touches 1 file; importers not recorded. No guarding tests found."),
+ ).toBeTruthy();
});
- it("always shows Verify, with the explicit message when nothing guards the file", () => {
+ it("opens Verify with the explicit message when nothing guards the file", () => {
renderDrawer(detail());
- expect(screen.getByText("Verify")).toBeTruthy();
- expect(screen.getByText(/No guarding tests found/)).toBeTruthy();
+ const verify = screen.getByRole("button", { name: /Verify/ });
+ expect(verify.getAttribute("aria-expanded")).toBe("true");
+ expect(verify.textContent).toContain("none guarding");
+ expect(screen.getByText(/Write one that pins the current behaviour/)).toBeTruthy();
+ });
+
+ it("keeps Verify collapsed when tests guard the file, counting each test once", () => {
+ const profile: Omit<RecommendationValidation, "total" | "tests"> = {
+ basis: "measured",
+ via: "call-graph",
+ truncated: false,
+ affected_files: [],
+ affected_symbols: [],
+ commands: [],
+ targets: [],
+ };
+ renderDrawer(
+ detail({
+ validation_profiles: [
+ { ...profile, id: "a", total: 2, tests: ["tests/test_a.py", "tests/test_b.py"] },
+ { ...profile, id: "b", total: 2, tests: ["tests/test_b.py", "tests/test_c.py"] },
+ ],
+ }),
+ );
+ const verify = screen.getByRole("button", { name: /Verify/ });
+ expect(verify.getAttribute("aria-expanded")).toBe("false");
+ expect(verify.textContent).toContain("3 tests");
+ expect(screen.getByText(/3 guarding tests reach it\./)).toBeTruthy();
+ });
+
+ it("keeps the agent id collapsed until asked for", () => {
+ renderDrawer(detail());
+ expect(screen.queryByText(/get_health\(opportunity_id=/)).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: /Ask for this by id/ }));
+ expect(screen.getByText(/get_health\(opportunity_id=/)).toBeTruthy();
});
it("reads the step's span from the file for an inline excerpt", async () => {
- const readSource = vi.fn().mockResolvedValue(["a = 1", "b = 2", "c = 3", "d = 4", "e = 5"].join(String.fromCharCode(10)));
+ const readSource = vi
+ .fn()
+ .mockResolvedValue(["a = 1", "b = 2", "c = 3", "d = 4", "e = 5"].join("\n"));
render(
<OpportunityDrawer
detail={detail({ steps: [STEP], steps_emitted: 1, plans: [PLAN] })}
@@ -155,6 +194,35 @@ describe("OpportunityDrawer reach, verification and code", () => {
expect(screen.getByText(/A diff preview is drafted by a model on request/)).toBeTruthy();
});
+ it("shows an extraction's slice under the helper's signature, not the whole function", async () => {
+ const readSource = vi
+ .fn()
+ .mockResolvedValue(["def f():", " a = 1", " b = 2", " c = 3", " return c"].join("\n"));
+ const plan = {
+ ...PLAN,
+ line_start: 1,
+ line_end: 5,
+ plan: { span: { start: 2, end: 3 }, params: [], returns: ["b"], suggested_name: "_setup" },
+ } as RefactoringPlan;
+ render(
+ <OpportunityDrawer
+ detail={detail({
+ steps: [{ ...STEP, line_start: 1, line_end: 5 }],
+ steps_emitted: 1,
+ plans: [plan],
+ })}
+ open
+ onOpenChange={() => {}}
+ readSource={readSource}
+ />,
+ );
+ fireEvent.click(screen.getByRole("button", { name: "Show the code" }));
+ expect(screen.getByText("_setup() -> b")).toBeTruthy();
+ expect(await screen.findByText("a = 1", { exact: false })).toBeTruthy();
+ expect(screen.queryByText("def f():")).toBeNull();
+ expect(screen.queryByText("return c", { exact: false })).toBeNull();
+ });
+
it("offers the model-drafted diff preview when the host turned generation on", () => {
render(
<OpportunityDrawer
@@ -168,3 +236,37 @@ describe("OpportunityDrawer reach, verification and code", () => {
expect(screen.getByRole("button", { name: /Generate code/ })).toBeTruthy();
});
});
+
+describe("RefactoringDrawer validation", () => {
+ const validation = {
+ basis: "unknown",
+ via: null,
+ total: 0,
+ tests: [],
+ truncated: false,
+ affected_files: [],
+ affected_symbols: [],
+ commands: [],
+ targets: [],
+ } as const;
+
+ it("opens Validation when no test guards the plan", () => {
+ render(
+ <RefactoringDrawer
+ plan={{ ...PLAN, validation } as unknown as RefactoringPlan}
+ open
+ onOpenChange={() => {}}
+ />,
+ );
+ const toggle = screen.getByRole("button", { name: /Validation/ });
+ expect(toggle.getAttribute("aria-expanded")).toBe("true");
+ expect(toggle.textContent).toContain("none guarding");
+ });
+
+ it("keeps Validation collapsed, with no count, when the plan carries none", () => {
+ render(<RefactoringDrawer plan={PLAN} open onOpenChange={() => {}} />);
+ const toggle = screen.getByRole("button", { name: /Validation/ });
+ expect(toggle.getAttribute("aria-expanded")).toBe("false");
+ expect(toggle.textContent).not.toContain("guarding");
+ });
+});
diff --git a/packages/ui/__tests__/refactoring/refactoring-lede.test.tsx b/packages/ui/__tests__/refactoring/refactoring-lede.test.tsx
new file mode 100644
index 000000000..7f5a806db
--- /dev/null
+++ b/packages/ui/__tests__/refactoring/refactoring-lede.test.tsx
@@ -0,0 +1,84 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import type { RefactoringRollupAvailable } from "@repowise-dev/types/refactoring";
+
+import { RefactoringLede } from "../../src/refactoring/refactoring-lede";
+
+const summary: RefactoringRollupAvailable = {
+ status: "available",
+ opportunities_total: 669,
+ files_total: 669,
+ steps_total: 1127,
+ mechanical_steps_total: 679,
+ judgment_steps_total: 448,
+ by_lead_type: { extract_method: 551, split_file: 118 },
+ by_effort: { S: 300, XL: 369 },
+ by_confidence: {},
+ by_status: { open: 669 },
+ addresses_primary_problem: { yes: 1, no: 2, unknown: 0 },
+ lead: null,
+ refactoring_model_version: 2,
+ analyzed_commit: null,
+};
+
+const facets = { effort: { S: 41 }, lead_type: { split_file: 7, extract_method: 70 } };
+
+describe("RefactoringLede", () => {
+ it("reads as two lines with chips counted from the facets", () => {
+ const onToggleQuickWins = vi.fn();
+ const onSeeStructural = vi.fn();
+ render(
+ <RefactoringLede
+ summary={summary}
+ facets={facets}
+ onToggleQuickWins={onToggleQuickWins}
+ onSeeStructural={onSeeStructural}
+ />,
+ );
+ expect(screen.getByText("118 change a file's shape; 551 are local.")).toBeTruthy();
+ expect(screen.getByText("679 of 1,127 steps are mechanical,")).toBeTruthy();
+ expect(screen.queryByText("Files with work")).toBeNull();
+
+ const quick = screen.getByRole("button", { name: "Quick wins 41" });
+ expect(quick.getAttribute("aria-pressed")).toBe("false");
+ fireEvent.click(quick);
+ expect(onToggleQuickWins).toHaveBeenCalledOnce();
+
+ // A jump to the structural tab, not a filter that could read as pressed.
+ const structural = screen.getByRole("button", { name: "See the 7 structural" });
+ expect(structural.hasAttribute("aria-pressed")).toBe(false);
+ fireEvent.click(structural);
+ expect(onSeeStructural).toHaveBeenCalledOnce();
+ });
+
+ it("marks Quick wins pressed while the list is narrowed to small effort", () => {
+ render(
+ <RefactoringLede
+ summary={summary}
+ facets={facets}
+ quickWinsActive
+ onToggleQuickWins={() => {}}
+ />,
+ );
+ const quick = screen.getByRole("button", { name: "Quick wins 41" });
+ expect(quick.getAttribute("aria-pressed")).toBe("true");
+ });
+
+ it("says all of it is local when nothing is structural", () => {
+ render(
+ <RefactoringLede
+ summary={{ ...summary, by_lead_type: { extract_method: 669 } }}
+ facets={{ effort: { S: 41 }, lead_type: { extract_method: 70 } }}
+ onToggleQuickWins={() => {}}
+ onSeeStructural={() => {}}
+ />,
+ );
+ expect(screen.getByText("All of it is local.")).toBeTruthy();
+ expect(screen.queryByRole("button", { name: /structural/ })).toBeNull();
+ });
+
+ it("drops the chips without facets", () => {
+ render(<RefactoringLede summary={summary} onToggleQuickWins={() => {}} />);
+ expect(screen.queryByRole("group", { name: "Filter the list" })).toBeNull();
+ });
+});
diff --git a/packages/ui/__tests__/shared/release-notice.test.tsx b/packages/ui/__tests__/shared/release-notice.test.tsx
new file mode 100644
index 000000000..b51d6869b
--- /dev/null
+++ b/packages/ui/__tests__/shared/release-notice.test.tsx
@@ -0,0 +1,29 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { ReleaseNotice } from "../../src/shared/release-notice";
+
+afterEach(() => window.localStorage.clear());
+
+describe("ReleaseNotice", () => {
+ it("reads as one line with the explanation behind a toggle", async () => {
+ const { container } = render(
+ <ReleaseNotice id="t" version="1.0.0" detail="Scores are not comparable.">
+ Health scores changed in this release.
+ </ReleaseNotice>,
+ );
+ expect(await screen.findByText("Health scores changed in this release.")).toBeTruthy();
+ const details = container.querySelector("details")!;
+ expect(details.open).toBe(false);
+ expect(screen.getByText("What changed")).toBeTruthy();
+ });
+
+ it("stays dismissed for the same release", async () => {
+ const { unmount } = render(<ReleaseNotice id="t" version="1.0.0">Changed.</ReleaseNotice>);
+ fireEvent.click(await screen.findByRole("button", { name: "Dismiss" }));
+ expect(screen.queryByText("Changed.")).toBeNull();
+ unmount();
+ render(<ReleaseNotice id="t" version="1.0.0">Changed.</ReleaseNotice>);
+ expect(screen.queryByText("Changed.")).toBeNull();
+ });
+});
diff --git a/packages/ui/src/health/fix-first/fix-first-list.tsx b/packages/ui/src/health/fix-first/fix-first-list.tsx
index 2185a360e..38c46da7e 100644
--- a/packages/ui/src/health/fix-first/fix-first-list.tsx
+++ b/packages/ui/src/health/fix-first/fix-first-list.tsx
@@ -2,22 +2,24 @@
/**
* Fix first: the ranked list of what to fix in this repository, as core built
- * it. The header states the scope exactly (shown of eligible, and what each
- * rule excluded); the list is the payload's order. Shared by every host: the
- * host fetches, routes and writes, this renders.
+ * it. The header states the scope exactly (shown of eligible); what each rule
+ * excluded is one click away in a popover; the list is the payload's order.
+ * Shared by every host: the host fetches, routes and writes, this renders.
*/
import { useCallback, useState, type ElementType } from "react";
import type { FixFirstQueue, FixItem, FixScope } from "@repowise-dev/types/fix-first";
import { Skeleton, SkeletonRegion } from "../../ui/skeleton";
+import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover";
import { ApiError } from "../../shared/api-error";
import { toFriendlyMessage } from "../../lib/errors";
import { OverviewSection } from "../../overview/section";
+import { formatNumber } from "../../lib/format";
import { AiPromptModal, fileChatContext } from "../ai-prompt-modal";
import type { AiPromptFlavor } from "../ai-prompt-builder";
import { FixFirstItem, type FixTriageStatus } from "./fix-first-item";
-import { fixFirstScopeSentence, fixLocation } from "./scope";
+import { exclusionEntries, fixFirstScopeSentence, fixLocation } from "./scope";
export interface FixFirstListProps {
queue: FixFirstQueue | undefined;
@@ -35,10 +37,7 @@ export interface FixFirstListProps {
LinkComponent?: ElementType | undefined;
/** Drop the section's top hairline when it opens the page. */
flush?: boolean | undefined;
- /**
- * Closed by default: the score leads Code Health, and Fix first sits under
- * it as one line with its count until the reader opens it.
- */
+ /** Open by default: the items are what the page asks the reader to do. */
defaultOpen?: boolean | undefined;
}
@@ -55,7 +54,7 @@ export function FixFirstList({
loadPrompt,
LinkComponent,
flush = false,
- defaultOpen = false,
+ defaultOpen = true,
}: FixFirstListProps) {
// Every row starts as its one or two scan lines; the detail opens per row.
const [expanded, setExpanded] = useState<ReadonlySet<string>>(() => new Set());
@@ -89,6 +88,24 @@ export function FixFirstList({
: undefined;
const count = queue ? queue.items.length : null;
+ const exclusions = queue ? exclusionEntries(queue.totals.excluded) : [];
+ const excludedTotal = exclusions.reduce((n, entry) => n + entry.count, 0);
+ const excludedControl =
+ excludedTotal > 0 ? (
+ <Popover>
+ <PopoverTrigger className="rounded text-xs text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-text-primary)] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]">
+ <span className="tabular-nums">{formatNumber(excludedTotal)}</span> excluded
+ </PopoverTrigger>
+ <PopoverContent align="start">
+ <p className="mb-1.5 text-[var(--color-text-tertiary)]">Left out of Fix first, by rule:</p>
+ <ul className="space-y-0.5 tabular-nums text-[var(--color-text-secondary)]">
+ {exclusions.map((entry) => (
+ <li key={entry.reason}>{entry.text}</li>
+ ))}
+ </ul>
+ </PopoverContent>
+ </Popover>
+ ) : null;
return (
<OverviewSection
@@ -99,9 +116,14 @@ export function FixFirstList({
{...(count !== null ? { hint: `${count} ${count === 1 ? "item" : "items"}` } : {})}
{...(description ? { description } : {})}
>
- {/* A collapsible section has no header action slot, so the toggle
- leads the body. */}
- {toggleTests ? <div>{toggleTests}</div> : null}
+ {/* A collapsible section has no header action slot, so the controls
+ lead the body. */}
+ {toggleTests || excludedControl ? (
+ <div className="flex flex-wrap items-center gap-x-4 gap-y-1">
+ {toggleTests}
+ {excludedControl}
+ </div>
+ ) : null}
{error ? (
<ApiError
title="Couldn't load Fix first"
@@ -116,8 +138,8 @@ export function FixFirstList({
</SkeletonRegion>
) : queue && queue.items.length === 0 ? (
<p className="text-sm text-[var(--color-text-secondary)]">
- Nothing eligible to fix first. Every candidate was excluded by a rule listed above, or the
- index has no health analysis yet.
+ Nothing eligible to fix first. Every candidate was excluded by a rule, or the index has
+ no health analysis yet.
</p>
) : queue ? (
<ol className="flex flex-col divide-y divide-[var(--color-border-default)]">
diff --git a/packages/ui/src/health/fix-first/scope.ts b/packages/ui/src/health/fix-first/scope.ts
index 558dede3c..95453bf6a 100644
--- a/packages/ui/src/health/fix-first/scope.ts
+++ b/packages/ui/src/health/fix-first/scope.ts
@@ -76,31 +76,47 @@ const EXCLUSION_ORDER: FixExclusion[] = [
/**
* The header line, exact about scope: how many items are shown out of how
- * many are eligible, what each rule left out, and how many functions a
- * constant flag keeps dormant. A zero count is omitted because it excluded
- * nothing.
+ * many are eligible, and how many functions a constant flag keeps dormant.
+ * What each rule left out is listed apart, by {@link exclusionEntries}.
*/
export function fixFirstScopeSentence(queue: FixFirstQueue<unknown>): string {
- const { shown, eligible, excluded, dormant } = queue.totals;
+ const { shown, eligible, dormant } = queue.totals;
const head = `${formatNumber(shown)} of ${formatNumber(eligible)} eligible item${
eligible === 1 ? "" : "s"
}.`;
- const parts = exclusionPhrase(excluded);
- const sentence = parts ? `${head} Excluded: ${parts}.` : head;
return dormant
- ? `${sentence} Dormant: ${formatNumber(dormant)} function${
+ ? `${head} Dormant: ${formatNumber(dormant)} function${
dormant === 1 ? "" : "s"
} behind a disabled flag.`
- : sentence;
+ : head;
+}
+
+export interface ExclusionEntry {
+ reason: FixExclusion;
+ count: number;
+ /** `612 in tests`. */
+ text: string;
+}
+
+/** Each nonzero exclusion count with its words, in the sentence order. A zero
+ * is omitted because it excluded nothing. */
+export function exclusionEntries(
+ counts: Partial<Record<FixExclusion, number>>,
+): ExclusionEntry[] {
+ return EXCLUSION_ORDER.filter((key) => (counts[key] ?? 0) > 0).map((key) => ({
+ reason: key,
+ count: counts[key] ?? 0,
+ text: `${formatNumber(counts[key] ?? 0)} ${EXCLUSION_LABEL[key]}`,
+ }));
}
/**
- * `3 in tests, 12 below the worth floor`: each nonzero exclusion count with
- * its words, in the sentence order. Empty when nothing was excluded.
+ * `3 in tests, 12 below the worth floor`: {@link exclusionEntries} as one
+ * phrase. Empty when nothing was excluded.
*/
export function exclusionPhrase(counts: Partial<Record<FixExclusion, number>>): string {
- return EXCLUSION_ORDER.filter((key) => (counts[key] ?? 0) > 0)
- .map((key) => `${formatNumber(counts[key] ?? 0)} ${EXCLUSION_LABEL[key]}`)
+ return exclusionEntries(counts)
+ .map((entry) => entry.text)
.join(", ");
}
diff --git a/packages/ui/src/health/performance/drawer.tsx b/packages/ui/src/health/performance/drawer.tsx
index a0bce87d8..d897d48e6 100644
--- a/packages/ui/src/health/performance/drawer.tsx
+++ b/packages/ui/src/health/performance/drawer.tsx
@@ -13,7 +13,9 @@ import type {
import type { RecommendationValidation, RefactoringPlan } from "@repowise-dev/types/refactoring";
import { AdaptivePanel } from "../../shared/adaptive-panel";
+import { CollapsibleSection } from "../../shared/collapsible-section";
import { InfoTip } from "../../shared/info-tip";
+import { formatNumber } from "../../lib/format";
import { ProvenancePathList } from "../../shared/provenance-path-list";
import { performancePlanDetail } from "../../refactoring/types";
import { SourceExcerpt } from "../../refactoring/source-excerpt";
@@ -314,14 +316,6 @@ function PlanSection({
</p>
) : null}
{steps && steps.length > 0 ? <PlanSteps steps={steps} /> : null}
- {opportunity.validation ? (
- <div className="mt-3">
- <ValidationSummary
- validation={toRecommendationValidation(opportunity.validation)}
- fileHref={adapter.fileHref}
- />
- </div>
- ) : null}
{planId && !enabled ? (
<p className="mt-2 text-xs text-[var(--color-text-tertiary)]">
This host cannot open the stored plan. Its id is{" "}
@@ -423,7 +417,73 @@ export function OpportunityDrawer({
<CodeSection opportunity={current} adapter={adapter} />
- <Section title="What the evidence shows">
+ {current.siblings && current.siblings.length > 0 ? (
+ <SiblingsNote siblings={current.siblings} onSelect={onSelectById} />
+ ) : null}
+
+ <Section title="Whether it can be changed">
+ <dl className="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
+ <Field
+ label="Actionability"
+ value={ACTIONABILITY_LABEL[current.actionability_state]}
+ detail={humanizeToken(current.actionability_reason)}
+ />
+ <Field
+ label="Actionability confidence"
+ value={CONFIDENCE_LABEL[current.facets.actionability_confidence]}
+ detail="Whether reducing the work is likely valid."
+ />
+ <Field
+ label="Fix safety"
+ value={current.fix ? humanizeToken(current.fix.safety) : "No named fix"}
+ detail={
+ current.fix
+ ? "Whether this one transformation is safe to apply."
+ : "No transformation was proposed, so none was judged safe."
+ }
+ />
+ </dl>
+ {current.prerequisites.length > 0 ? (
+ <div className="mt-3">
+ <p className="text-xs text-[var(--color-text-tertiary)]">
+ Missing before a fix can be named:
+ </p>
+ <ul className="mt-1 list-inside list-disc text-xs text-[var(--color-text-secondary)]">
+ {current.prerequisites.map((item) => (
+ <li key={item}>{humanizeToken(item)}</li>
+ ))}
+ </ul>
+ </div>
+ ) : null}
+ </Section>
+
+ <PlanSection
+ opportunity={current}
+ adapter={adapter}
+ enabled={planEnabled}
+ plan={plan}
+ />
+
+ <RelatedSection adapter={adapter} filePath={current.file_path} />
+
+ {current.validation ? (
+ <CollapsibleSection
+ title="Tests"
+ hint={
+ current.validation.total > 0
+ ? `${formatNumber(current.validation.total)} guarding`
+ : "none guarding"
+ }
+ defaultOpen={current.validation.total === 0}
+ >
+ <ValidationSummary
+ validation={toRecommendationValidation(current.validation)}
+ fileHref={adapter.fileHref}
+ />
+ </CollapsibleSection>
+ ) : null}
+
+ <CollapsibleSection title="What the evidence shows">
<dl className="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
<Field label="Context" value={contextLabel(current.execution_context)} />
<Field label="Boundary" value={boundaryLabel(current.boundary_kind)} />
@@ -465,48 +525,9 @@ export function OpportunityDrawer({
/>
) : null}
</dl>
- {current.siblings && current.siblings.length > 0 ? (
- <SiblingsNote siblings={current.siblings} onSelect={onSelectById} />
- ) : null}
- </Section>
+ </CollapsibleSection>
- <Section title="Whether it can be changed">
- <dl className="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
- <Field
- label="Actionability"
- value={ACTIONABILITY_LABEL[current.actionability_state]}
- detail={humanizeToken(current.actionability_reason)}
- />
- <Field
- label="Actionability confidence"
- value={CONFIDENCE_LABEL[current.facets.actionability_confidence]}
- detail="Whether reducing the work is likely valid."
- />
- <Field
- label="Fix safety"
- value={current.fix ? humanizeToken(current.fix.safety) : "No named fix"}
- detail={
- current.fix
- ? "Whether this one transformation is safe to apply."
- : "No transformation was proposed, so none was judged safe."
- }
- />
- </dl>
- {current.prerequisites.length > 0 ? (
- <div className="mt-3">
- <p className="text-xs text-[var(--color-text-tertiary)]">
- Missing before a fix can be named:
- </p>
- <ul className="mt-1 list-inside list-disc text-xs text-[var(--color-text-secondary)]">
- {current.prerequisites.map((item) => (
- <li key={item}>{humanizeToken(item)}</li>
- ))}
- </ul>
- </div>
- ) : null}
- </Section>
-
- <Section title="Why it ranks here">
+ <CollapsibleSection title="Why it ranks here">
<p className="text-sm text-[var(--color-text-secondary)]">
Position <span className="tabular-nums">{current.rank_position.toLocaleString()}</span>{" "}
in the queue.
@@ -520,19 +541,10 @@ export function OpportunityDrawer({
))}
</ul>
) : null}
- </Section>
-
- <PlanSection
- opportunity={current}
- adapter={adapter}
- enabled={planEnabled}
- plan={plan}
- />
-
- <RelatedSection adapter={adapter} filePath={current.file_path} />
+ </CollapsibleSection>
{current.evidence.some((item) => item.path.length > 0) ? (
- <Section title="Caller to sink paths">
+ <CollapsibleSection title="Caller to sink paths">
<ProvenancePathList
paths={current.evidence
.filter((item) => item.path.length > 0)
@@ -541,7 +553,7 @@ export function OpportunityDrawer({
fileHref={adapter.fileHref}
{...(adapter.symbolHref ? { symbolHref: adapter.symbolHref } : {})}
/>
- </Section>
+ </CollapsibleSection>
) : null}
<RawObservations
@@ -552,7 +564,7 @@ export function OpportunityDrawer({
adapter={adapter}
/>
- <Section title="Hand this to an agent">
+ <CollapsibleSection title="Hand this to an agent">
<p className="text-sm text-[var(--color-text-secondary)]">
Ask for the same record by its stable id:
</p>
@@ -565,7 +577,7 @@ export function OpportunityDrawer({
<span className="font-mono">{resolved.analyzed_commit.slice(0, 7)}</span>.
</p>
) : null}
- </Section>
+ </CollapsibleSection>
</div>
<div className="flex items-center gap-3 border-t border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-5 py-3.5">
diff --git a/packages/ui/src/health/performance/presentation.ts b/packages/ui/src/health/performance/presentation.ts
index 32bcc10b7..7967e7bd7 100644
--- a/packages/ui/src/health/performance/presentation.ts
+++ b/packages/ui/src/health/performance/presentation.ts
@@ -72,8 +72,11 @@ const PROOF_LABEL: Record<PerformanceCostProof, string> = {
unproven: "Unproven: loop size unknown",
};
+// "Stored plan", not "Plan ready": that name belongs to the actionability
+// state, which the Plan ready tile counts. A stored plan is counted by the
+// "With a stored plan" tile, so the row mark and its tile share one predicate.
const PLAN_STATE_LABEL: Record<string, string> = {
- available: "Plan ready",
+ available: "Stored plan",
no_safe_plan: "No safe plan",
not_persisted: "Needs an index refresh",
};
@@ -322,7 +325,7 @@ export interface PlanPresentation {
export function planPresentation(opportunity: PerformanceOpportunity): PlanPresentation {
if (opportunity.plan_status === "available" && opportunity.plan_id) {
return {
- label: "Structured plan ready",
+ label: PLAN_STATE_LABEL.available!,
detail: opportunity.plan_reason,
actionable: true,
};
diff --git a/packages/ui/src/refactoring/opportunity-drawer.tsx b/packages/ui/src/refactoring/opportunity-drawer.tsx
index 9b6636b8d..37017a547 100644
--- a/packages/ui/src/refactoring/opportunity-drawer.tsx
+++ b/packages/ui/src/refactoring/opportunity-drawer.tsx
@@ -29,6 +29,7 @@ import { Layers, Sparkles, Terminal } from "lucide-react";
import { Sheet, SheetContent, SheetTitle } from "../ui/sheet";
import { Skeleton, SkeletonRegion } from "../ui/skeleton";
+import { CollapsibleSection } from "../shared/collapsible-section";
import { formatNumber } from "../lib/format";
import { ValidationSummary } from "./validation-summary";
import { CONFIDENCE_LABEL, EFFORT_LABEL, typeMeta } from "./meta";
@@ -36,7 +37,7 @@ import { CodeBlock } from "./plan-detail";
import { SourceExcerpt } from "./source-excerpt";
import { RelatedWork, type RelatedWorkSlotProps } from "../health/related-work";
import { GenerateCodePanel } from "./generate-code-panel";
-import { extractHelperDetail } from "./types";
+import { extractHelperDetail, extractMethodSignature, stepExcerptRange } from "./types";
import {
ORDERING_NOTE,
STATUS_LABEL,
@@ -204,6 +205,8 @@ function DrawerBody({
// drawer, triage included, still describes a real opportunity.
const stepsUnavailable = detail.details_status === "unavailable";
const anyRelocated = detail.steps.some(isRelocated);
+ const guarding = guardingTestCount(detail.validation_profiles);
+ const guardingTests = guarding.count;
const [pending, setPending] = React.useState<OpportunityStatus | null>(null);
const [failed, setFailed] = React.useState(false);
@@ -266,7 +269,10 @@ function DrawerBody({
</div>
<p className="border-b border-[var(--color-border-default)] px-5 py-2 text-[12px] text-[var(--color-text-secondary)]">
- {blastRadiusLine(detail)}
+ {blastRadiusLine(detail)}{" "}
+ {guardingTests > 0
+ ? `${guarding.atLeast ? "At least " : ""}${formatNumber(guardingTests)} guarding test${guardingTests === 1 ? "" : "s"} reach it.`
+ : "No guarding tests found."}
</p>
<div className="flex-1 space-y-6 overflow-y-auto px-5 py-5">
@@ -360,12 +366,13 @@ function DrawerBody({
) : null}
</section>
- {/* Always present: "nothing guards this" is the answer a person most
- needs before changing the file, so its absence is said, not hidden. */}
- <section>
- <h4 className="mb-3 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Verify
- </h4>
+ {/* Detail below the steps is collapsed: the line under the facts already
+ says whether tests guard the file, which is what a person decides on. */}
+ <CollapsibleSection
+ title="Verify"
+ hint={guardingTests > 0 ? `${formatNumber(guardingTests)} tests` : "none guarding"}
+ defaultOpen={guardingTests === 0}
+ >
{detail.validation_profiles.length > 0 ? (
<div className="space-y-4">
{detail.validation_profiles.map((profile) => (
@@ -382,7 +389,7 @@ function DrawerBody({
these steps.
</p>
)}
- </section>
+ </CollapsibleSection>
<RelatedWork
related={related?.file_path === detail.file_path ? related : null}
@@ -393,10 +400,7 @@ function DrawerBody({
/>
{detail.evidence.length > 0 ? (
- <section>
- <h4 className="mb-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Evidence
- </h4>
+ <CollapsibleSection title="Evidence" hint={formatNumber(detail.evidence_total)}>
{/* Named as observation, not instruction. These are mostly demoted
clone groups: real duplication, not a change worth making on its
own account. */}
@@ -426,15 +430,19 @@ function DrawerBody({
Showing {detail.evidence_emitted} of {detail.evidence_total} observations.
</p>
) : null}
- </section>
+ </CollapsibleSection>
) : null}
{others.length > 0 ? (
- <section>
- <h4 className="mb-2 flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- <Layers className="h-3.5 w-3.5" />
- Also affected
- </h4>
+ <CollapsibleSection
+ title={
+ <span className="flex items-center gap-1.5">
+ <Layers className="h-3.5 w-3.5" aria-hidden="true" />
+ Also affected
+ </span>
+ }
+ hint={formatNumber(others.length)}
+ >
<ul className="space-y-1">
{others.map((f) => {
const href = fileHref?.(f, null);
@@ -456,14 +464,17 @@ function DrawerBody({
);
})}
</ul>
- </section>
+ </CollapsibleSection>
) : null}
- <section>
- <h4 className="mb-2 flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- <Terminal className="h-3.5 w-3.5" />
- Ask for this by id
- </h4>
+ <CollapsibleSection
+ title={
+ <span className="flex items-center gap-1.5">
+ <Terminal className="h-3.5 w-3.5" aria-hidden="true" />
+ Ask for this by id
+ </span>
+ }
+ >
<p className="text-[12.5px] text-[var(--color-text-secondary)]">
Copy the prompt with the Claude + MCP flavor and it carries this call, so the agent
can pull the same record itself rather than working from the pasted copy. The other
@@ -472,7 +483,7 @@ function DrawerBody({
<p className="mt-1.5 break-all rounded bg-[var(--color-bg-inset)] px-2 py-1.5 font-mono text-xs text-[var(--color-text-primary)]">
{opportunityHandoffCall(detail.opportunity_id)}
</p>
- </section>
+ </CollapsibleSection>
</div>
{/* The prompt carries the ordered steps; without them it would hand an
@@ -601,7 +612,9 @@ function StepCard({
* Closed by default: a drawer of seven open excerpts would bury the order of
* the steps, which is the drawer's subject. The excerpt prefers the text the
* stored plan carries (an extract-helper block); otherwise it reads the file
- * the way the file view does and cuts the step's span out of it.
+ * the way the file view does and cuts out the lines the step changes. For an
+ * extraction that is the slice, under the helper's proposed signature, not the
+ * whole function the step's span covers.
*/
function StepCode({
step,
@@ -616,7 +629,10 @@ function StepCode({
}) {
const [open, setOpen] = React.useState(false);
const stored = plan ? extractHelperDetail(plan) : null;
- const canRead = Boolean(readSource && step.line_start);
+ const range = stepExcerptRange(step, plan);
+ const extraction = range?.extraction ?? null;
+ const slice = extraction?.span ?? null;
+ const canRead = Boolean(readSource && range);
if (!stored?.snippet && !canRead && !plan) return null;
return (
<div className="mt-2">
@@ -630,13 +646,21 @@ function StepCode({
</button>
{open ? (
<div className="mt-2 space-y-3">
+ {extraction && slice ? (
+ <p className="text-[11.5px] text-[var(--color-text-tertiary)]">
+ Lines {slice.start} to {slice.end} become{" "}
+ <code className="break-all font-mono text-[var(--color-text-primary)]">
+ {extractMethodSignature(extraction)}
+ </code>
+ </p>
+ ) : null}
{stored?.snippet ? (
<CodeBlock code={stored.snippet} startLine={stored.snippetStartLine} />
) : canRead ? (
<SourceExcerpt
path={step.file_path}
- start={step.line_start!}
- end={step.line_end ?? step.line_start!}
+ start={range!.start}
+ end={range!.end}
readSource={readSource!}
/>
) : null}
@@ -653,6 +677,24 @@ function StepCode({
);
}
+/**
+ * Distinct guarding tests across an opportunity's validation profiles.
+ *
+ * Profiles are deduplicated by their whole content, so two steps with
+ * different validations get two profiles that can name the same tests:
+ * summing `total` would count those twice. A truncated profile lists only
+ * some of its tests, so the count is then a floor, never less than any one
+ * profile's total.
+ */
+export function guardingTestCount(
+ profiles: ReadonlyArray<{ total: number; tests: string[]; truncated?: boolean | undefined }>,
+): { count: number; atLeast: boolean } {
+ const distinct = new Set(profiles.flatMap((profile) => profile.tests)).size;
+ const largest = profiles.reduce((n, profile) => Math.max(n, profile.total), 0);
+ const atLeast = profiles.length > 1 && profiles.some((p) => p.truncated || p.tests.length < p.total);
+ return { count: Math.max(distinct, largest), atLeast };
+}
+
/**
* Who else the change reaches, in one line, for every type: the files the
* steps edit, and the files that import the lead file when the store has it.
diff --git a/packages/ui/src/refactoring/plan-detail.tsx b/packages/ui/src/refactoring/plan-detail.tsx
index 29acc87ac..e3986b622 100644
--- a/packages/ui/src/refactoring/plan-detail.tsx
+++ b/packages/ui/src/refactoring/plan-detail.tsx
@@ -10,6 +10,7 @@ import {
extractHelperDetail,
extractHelperOccurrences,
extractMethodPlan,
+ extractMethodSignature,
helperSite,
moveTarget,
performancePlanDetail,
@@ -428,10 +429,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
const em = extractMethodPlan(plan);
const lines = em.span ? em.span.end - em.span.start + 1 : 0;
const ccn = Number(plan.evidence?.ccn_removed ?? 0);
- const helperName = em.suggested_name ?? "helper";
- const sig = `${em.needs_async ? "async " : ""}${helperName}(${em.params.join(", ")})${
- em.returns.length ? ` -> ${em.returns.join(", ")}` : ""
- }`;
+ const sig = extractMethodSignature(em);
return (
<div className="space-y-3">
{hideIntro ? null : (
diff --git a/packages/ui/src/refactoring/refactoring-board.tsx b/packages/ui/src/refactoring/refactoring-board.tsx
index 6f9c6e79e..1e18a9533 100644
--- a/packages/ui/src/refactoring/refactoring-board.tsx
+++ b/packages/ui/src/refactoring/refactoring-board.tsx
@@ -43,7 +43,7 @@ import { Segmented } from "../shared/segmented";
import { exclusionPhrase } from "../health/fix-first/scope";
import { formatNumber } from "../lib/format";
import { OpportunityRows } from "./opportunity-rows";
-import { RefactoringLede } from "./refactoring-lede";
+import { RefactoringLede, type RefactoringFacets } from "./refactoring-lede";
import { StartHere } from "./start-here";
import { CONFIDENCE_LABEL, EFFORT_LABEL } from "./meta";
import { STATUS_LABEL, TRIAGE_STATUSES } from "./opportunity";
@@ -99,11 +99,12 @@ export interface RefactoringBoardProps {
opportunities: RefactoringOpportunity[];
/** The repository rollup the endpoint returns. Feeds the lede. */
summary?: RefactoringOpportunityRollup | null | undefined;
+ /** The page's facet counts, which the lede's filter chips count. */
+ facets?: RefactoringFacets | null | undefined;
/** Bounded structural head for Start here, already filtered to lead types. */
structuralOpportunities?: RefactoringOpportunity[] | undefined;
serverState: RefactoringBoardServerState;
onServerStateChange: (change: Partial<RefactoringBoardServerState>) => void;
- indexedFileCount?: number | undefined;
onOpen?: ((opportunity: RefactoringOpportunity) => void) | undefined;
onAiPrompt?: ((opportunity: RefactoringOpportunity) => void) | undefined;
onStatusChange?:
@@ -125,10 +126,10 @@ export interface RefactoringBoardProps {
export function RefactoringBoard({
opportunities,
summary,
+ facets,
structuralOpportunities,
serverState,
onServerStateChange,
- indexedFileCount,
onOpen,
onAiPrompt,
onStatusChange,
@@ -175,10 +176,20 @@ export function RefactoringBoard({
const hiddenTotal = serverState.hidden?.total ?? 0;
const hiddenWhy = serverState.hidden ? exclusionPhrase(serverState.hidden.by_reason) : "";
+ const quickWinsActive = serverState.effort === "S";
+ const toggleQuickWins = () =>
+ onServerStateChange({ effort: quickWinsActive ? null : "S", offset: 0 });
+
return (
<div className="space-y-10">
{showLede ? (
- <RefactoringLede summary={summary} indexedFileCount={indexedFileCount} />
+ <RefactoringLede
+ summary={summary}
+ facets={facets}
+ quickWinsActive={quickWinsActive}
+ onToggleQuickWins={toggleQuickWins}
+ onSeeStructural={onSeeStructural}
+ />
) : null}
{showLede && (structuralOpportunities?.length ?? 0) > 0 ? (
diff --git a/packages/ui/src/refactoring/refactoring-drawer.tsx b/packages/ui/src/refactoring/refactoring-drawer.tsx
index 6a6701f9c..0342b1db8 100644
--- a/packages/ui/src/refactoring/refactoring-drawer.tsx
+++ b/packages/ui/src/refactoring/refactoring-drawer.tsx
@@ -22,6 +22,7 @@
import type { ReactNode } from "react";
import { Layers, Sparkles, TrendingUp, Wand2 } from "lucide-react";
+import { CollapsibleSection } from "../shared/collapsible-section";
import { Sheet, SheetContent, SheetTitle } from "../ui/sheet";
import { Skeleton, SkeletonRegion } from "../ui/skeleton";
import { formatNumber } from "../lib/format";
@@ -179,23 +180,6 @@ function DrawerBody({
<PlanComparison plan={plan} fileHref={fileHref} />
</section>
- <section>
- <h4 className="mb-3 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Priority
- </h4>
- <PriorityExplanation plan={plan} />
- </section>
-
- <section>
- <h4 className="mb-3 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Validation
- </h4>
- <ValidationSummary
- validation={plan.validation}
- fileHref={(path) => fileHref?.(path, null)}
- />
- </section>
-
{onGenerateCode ? (
<section>
<div className="mb-3 flex items-center justify-between gap-3">
@@ -244,10 +228,7 @@ function DrawerBody({
) : null}
{evidence.length > 0 ? (
- <section>
- <h4 className="mb-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Why this was flagged
- </h4>
+ <CollapsibleSection title="Why this was flagged">
<dl className="grid grid-cols-2 sm:grid-cols-4">
{evidence.map((row) => (
<div
@@ -263,15 +244,19 @@ function DrawerBody({
</div>
))}
</dl>
- </section>
+ </CollapsibleSection>
) : null}
{blast.length > 0 ? (
- <section>
- <h4 className="mb-2 flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- <Layers className="h-3.5 w-3.5" />
- Also affected
- </h4>
+ <CollapsibleSection
+ title={
+ <span className="flex items-center gap-1.5">
+ <Layers className="h-3.5 w-3.5" aria-hidden="true" />
+ Also affected
+ </span>
+ }
+ hint={formatNumber(blast.length)}
+ >
<ul className="space-y-1">
{blast.map((f) => {
const href = fileHref?.(f, null);
@@ -293,8 +278,29 @@ function DrawerBody({
);
})}
</ul>
- </section>
+ </CollapsibleSection>
) : null}
+
+ <CollapsibleSection
+ title="Validation"
+ hint={
+ plan.validation
+ ? plan.validation.total > 0
+ ? `${formatNumber(plan.validation.total)} tests`
+ : "none guarding"
+ : undefined
+ }
+ defaultOpen={plan.validation?.total === 0}
+ >
+ <ValidationSummary
+ validation={plan.validation}
+ fileHref={(path) => fileHref?.(path, null)}
+ />
+ </CollapsibleSection>
+
+ <CollapsibleSection title="Priority">
+ <PriorityExplanation plan={plan} />
+ </CollapsibleSection>
</div>
{onAiPrompt ? (
diff --git a/packages/ui/src/refactoring/refactoring-lede.tsx b/packages/ui/src/refactoring/refactoring-lede.tsx
index 4aa50e920..fc9726eea 100644
--- a/packages/ui/src/refactoring/refactoring-lede.tsx
+++ b/packages/ui/src/refactoring/refactoring-lede.tsx
@@ -1,63 +1,59 @@
/**
- * The Refactoring page's opening read.
+ * The Refactoring page's opening read: the figure, two lines, and the chips
+ * that filter the list to the subsets the lines name.
*
- * The surface used to open on a priority-by-effort scatter with no sentence
- * anywhere above it, which made it the only ported page with no lede. The
- * figure alone is also actively misleading: "1,819 plans" reads as a backlog you
- * are failing at, when most of it is small local tidy-ups you do while already
- * in the file.
- *
- * It counted plans until the page's unit became the opportunity, and then it
- * counted nothing at all: the page stopped fetching the plan list, so every
- * figure here silently read zero while the board below it showed 581 rows. The
- * fix is not to re-fetch plans - it is to say the thing the composed unit
- * actually knows, which is a better story anyway. Every number comes off the
- * repository rollup the board already loads, so the lede and the list cannot
- * disagree.
- *
- * The fact worth leading with changed too. It is no longer "most of this is
- * small" - it is how much of the work is *mechanical*, and how much of it
- * addresses what is actually wrong with the file. Both are honest and both were
- * unsayable before composition.
+ * Every figure in the prose comes off the repository rollup the board already
+ * loads. The chip counts come off the page's facets instead, because a chip
+ * filters the list and must count what the click will show: the facets follow
+ * the status and scope the list is in, and the rollup does not.
*/
import type { ReactNode } from "react";
import { PageLede } from "../shared/page-lede";
-import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";
+import { FilterChip } from "../health/code-health-controls";
import { formatNumber } from "../lib/format";
-import { typeMeta } from "./meta";
import { STRUCTURAL_TYPES } from "./types";
-import type { RefactoringOpportunityRollup } from "@repowise-dev/types/refactoring";
+import type {
+ RefactoringOpportunityPage,
+ RefactoringOpportunityRollup,
+} from "@repowise-dev/types/refactoring";
+
+/** The page's facet counts, by facet then value. */
+export type RefactoringFacets = RefactoringOpportunityPage["facets"];
export interface RefactoringLedeProps {
/** The repository rollup. Absent or unavailable and the lede does not render. */
summary?: RefactoringOpportunityRollup | null | undefined;
- /** Files in the repo, for the "581 of 4,952 indexed" denominator. Omit and
- * the ribbon drops the comparison rather than inventing one. */
- indexedFileCount?: number | undefined;
+ /** The page's facet counts. Absent and the chips do not render. */
+ facets?: RefactoringFacets | null | undefined;
+ /** Whether the list is narrowed to small effort, which the Quick wins chip toggles. */
+ quickWinsActive?: boolean;
+ onToggleQuickWins?: (() => void) | undefined;
+ /** Jump to the structural set. A link, not a filter: it changes the tab. */
+ onSeeStructural?: (() => void) | undefined;
/** Rendered under the prose. */
action?: ReactNode;
}
-/** "46 files to split, 13 cycles to cut and 6 classes doing two jobs" - built
- * rather than interpolated so a repo with one kind does not read "and". */
-function joinPhrases(parts: string[]): string {
- if (parts.length <= 1) return parts[0] ?? "";
- return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
+/** Counts summed over the structural lead types. */
+function sumStructural(byType: Record<string, number> | undefined): number {
+ return (STRUCTURAL_TYPES as readonly string[]).reduce((n, type) => n + (byType?.[type] ?? 0), 0);
}
-/** What each structural type is, in the words someone would use out loud. */
-const STRUCTURAL_PHRASE: Record<string, (n: number) => string> = {
- split_file: (n) => `${n} file${n === 1 ? "" : "s"} large enough to split along a real seam`,
- break_cycle: (n) => `${n} import cycle${n === 1 ? "" : "s"} with a cuttable edge`,
- extract_class: (n) => `${n} class${n === 1 ? "" : "es"} doing more than one job`,
- move_method: (n) => `${n} method${n === 1 ? "" : "s"} living on the wrong class`,
-};
+function plural(n: number, one: string, many: string): string {
+ return `${formatNumber(n)} ${n === 1 ? one : many}`;
+}
-export function RefactoringLede({ summary, indexedFileCount, action }: RefactoringLedeProps) {
+export function RefactoringLede({
+ summary,
+ facets,
+ quickWinsActive = false,
+ onToggleQuickWins,
+ onSeeStructural,
+ action,
+}: RefactoringLedeProps) {
// No analysis is a different state from no work, and the board says which.
- // The lede has nothing to open with either way.
if (!summary || summary.status !== "available") return null;
const total = summary.opportunities_total;
@@ -66,112 +62,64 @@ export function RefactoringLede({ summary, indexedFileCount, action }: Refactori
const mechanical = summary.mechanical_steps_total;
const judgment = summary.judgment_steps_total;
- const byLead = summary.by_lead_type ?? {};
- const structuralByType = (STRUCTURAL_TYPES as readonly string[])
- .map((type) => [type, byLead[type] ?? 0] as const)
- .filter(([, n]) => n > 0)
- .sort((a, b) => b[1] - a[1]);
- const structuralTotal = structuralByType.reduce((n, [, count]) => n + count, 0);
- const local = Math.max(0, total - structuralTotal);
-
- const small = summary.by_effort?.S ?? 0;
- const smallPct = total ? Math.round((small / total) * 100) : 0;
- const mechanicalPct = steps ? Math.round((mechanical / steps) * 100) : 0;
+ const structural = sumStructural(summary.by_lead_type);
+ const local = Math.max(0, total - structural);
- const primary = summary.addresses_primary_problem;
- const addressesLead = primary?.yes ?? 0;
- const addressesSide = primary?.no ?? 0;
- const addressesUnknown = primary?.unknown ?? 0;
-
- const structuralPhrase = joinPhrases(
- structuralByType.map(
- ([type, n]) => STRUCTURAL_PHRASE[type]?.(n) ?? `${n} ${typeMeta(type).label.toLowerCase()}`,
- ),
- );
-
- const stats: RibbonStat[] = [
- {
- label: "Files with work",
- value: formatNumber(files),
- sub: indexedFileCount ? `of ${formatNumber(indexedFileCount)} indexed` : "one each",
- },
- {
- label: "Steps to apply",
- value: formatNumber(steps),
- sub: `${formatNumber(mechanical)} mechanical, ${formatNumber(judgment)} judgment`,
- },
- {
- label: "Rated small effort",
- value: total ? `${smallPct}%` : "0%",
- sub: `${formatNumber(small)} opportunit${small === 1 ? "y" : "ies"}`,
- },
- {
- label: "Change a file's shape",
- value: formatNumber(structuralTotal),
- sub: structuralTotal ? "structural, and they lead the page" : "none in this repo",
- },
- ];
+ const quickWins = facets?.effort?.S ?? 0;
+ const structuralShown = sumStructural(facets?.lead_type);
+ const showQuickWins = onToggleQuickWins && (quickWins > 0 || quickWinsActive);
+ const showStructural = onSeeStructural && structuralShown > 0;
return (
- <div className="space-y-6">
- <PageLede
- label="Open opportunities"
- value={formatNumber(total)}
- unit={files ? `one per file, across ${formatNumber(files)} file${files === 1 ? "" : "s"}` : undefined}
- layout="beside"
- action={action}
- figureFooter={
- steps > 0 ? (
- <p className="text-caption text-[var(--color-text-tertiary)]">
- {formatNumber(steps)} step{steps === 1 ? "" : "s"} in total, so most files carry more
- than one.
- </p>
- ) : undefined
- }
- >
+ <PageLede
+ label="Open opportunities"
+ value={formatNumber(total)}
+ unit={files ? `one per file, across ${plural(files, "file", "files")}` : undefined}
+ action={action}
+ >
+ <p>
+ <span className="font-medium text-[var(--color-text-primary)]">
+ {structural > 0
+ ? `${plural(structural, "changes", "change")} a file's shape; ${plural(local, "is", "are")} local.`
+ : "All of it is local."}
+ </span>{" "}
+ Local work lifts a slice of a long function or tidies a repeated block, worth doing while
+ you are in the file.
+ </p>
+ {steps > 0 ? (
<p>
<span className="font-medium text-[var(--color-text-primary)]">
- {mechanicalPct}% of the steps are mechanical.
+ {formatNumber(mechanical)} of {plural(steps, "step is", "steps are")} mechanical,
</span>{" "}
- {formatNumber(mechanical)} of {formatNumber(steps)} have every proof obligation met, so
- they are safe to hand to an agent as written. The other {formatNumber(judgment)} change
- where something lives or what it is called, and want a person&apos;s judgment first.
+ ready to hand to an agent as written; the other {formatNumber(judgment)} want a
+ person&apos;s judgment first.
</p>
- {addressesSide > 0 || addressesLead > 0 ? (
- <p>
- <span className="font-medium text-[var(--color-text-primary)]">
- {formatNumber(addressesLead)} address the file&apos;s main problem.
- </span>{" "}
- {formatNumber(addressesSide)} do not - they are real work, but not the biggest cost in
- that file
- {addressesUnknown > 0
- ? `, and for ${formatNumber(addressesUnknown)} no dominant problem was recorded to compare against`
- : ""}
- . Each row says which, so nothing here claims to fix more than it does.
- </p>
- ) : null}
- {local > 0 ? (
- <p>
- <span className="font-medium text-[var(--color-text-primary)]">
- Most of this list is local.
- </span>{" "}
- {formatNumber(local)} opportunit{local === 1 ? "y lifts" : "ies lift"} a slice of a long
- function or tidy a repeated block, and {smallPct}% are rated small effort. They are
- worth doing when you are already in the file, and they are not worth a planning meeting.
- </p>
- ) : null}
- {structuralTotal > 0 ? (
- <p>
- <span className="font-medium text-[var(--color-text-primary)]">
- {formatNumber(structuralTotal)}{" "}
- {structuralTotal === 1 ? "is structural" : "are structural"}.
- </span>{" "}
- {structuralPhrase}. These change how the codebase is shaped, so they lead the page.
- </p>
- ) : null}
- </PageLede>
-
- <StatRibbon stats={stats} />
- </div>
+ ) : null}
+ {showQuickWins || showStructural ? (
+ <div
+ className="flex flex-wrap items-center gap-x-4 gap-y-2 pt-1"
+ role="group"
+ aria-label="Filter the list"
+ >
+ {showQuickWins ? (
+ <FilterChip active={quickWinsActive} onClick={onToggleQuickWins}>
+ Quick wins{" "}
+ <span className="font-mono tabular-nums">{formatNumber(quickWins)}</span>
+ </FilterChip>
+ ) : null}
+ {showStructural ? (
+ <button
+ type="button"
+ onClick={onSeeStructural}
+ className="rounded text-xs text-[var(--color-accent-primary)] underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]"
+ >
+ See the{" "}
+ <span className="font-mono tabular-nums">{formatNumber(structuralShown)}</span>{" "}
+ structural
+ </button>
+ ) : null}
+ </div>
+ ) : null}
+ </PageLede>
);
}
diff --git a/packages/ui/src/refactoring/types.ts b/packages/ui/src/refactoring/types.ts
index 769f415c5..3fc9449f2 100644
--- a/packages/ui/src/refactoring/types.ts
+++ b/packages/ui/src/refactoring/types.ts
@@ -180,6 +180,28 @@ export function extractMethodPlan(plan: RefactoringPlan): ExtractMethodPlan {
};
}
+/** The helper an extraction proposes, as one line: `async name(a, b) -> c`. */
+export function extractMethodSignature(em: ExtractMethodPlan): string {
+ const name = em.suggested_name ?? "helper";
+ const returns = em.returns.length ? ` -> ${em.returns.join(", ")}` : "";
+ return `${em.needs_async ? "async " : ""}${name}(${em.params.join(", ")})${returns}`;
+}
+
+/**
+ * The lines "Show the code" reads for a step: an extraction's stored slice,
+ * otherwise the step's own span. A step's span is the whole function it
+ * changes, which for an extraction is far more than the lines that move.
+ */
+export function stepExcerptRange(
+ step: { line_start: number | null; line_end: number | null },
+ plan: RefactoringPlan | undefined,
+): { start: number; end: number; extraction: ExtractMethodPlan | null } | null {
+ const extraction = plan?.refactoring_type === "extract_method" ? extractMethodPlan(plan) : null;
+ if (extraction?.span) return { ...extraction.span, extraction };
+ if (!step.line_start) return null;
+ return { start: step.line_start, end: step.line_end ?? step.line_start, extraction };
+}
+
export interface SplitGroup {
name: string | null;
symbols: string[];
diff --git a/packages/ui/src/shared/collapsible-section.tsx b/packages/ui/src/shared/collapsible-section.tsx
index c68ccd2d2..1f64f2d1a 100644
--- a/packages/ui/src/shared/collapsible-section.tsx
+++ b/packages/ui/src/shared/collapsible-section.tsx
@@ -25,15 +25,19 @@ export function CollapsibleSection({
className,
}: CollapsibleSectionProps) {
const [open, setOpen] = React.useState(defaultOpen);
+ const bodyId = React.useId();
return (
<section className={cn("space-y-3", className)}>
<button
type="button"
onClick={() => setOpen((v) => !v)}
aria-expanded={open}
+ aria-controls={bodyId}
className="flex w-full items-center gap-2 rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] px-3 py-2 text-sm font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]"
>
- <span className="text-[var(--color-text-tertiary)]">{open ? "▾" : "▸"}</span>
+ <span aria-hidden="true" className="text-[var(--color-text-tertiary)]">
+ {open ? "▾" : "▸"}
+ </span>
{title}
{hint != null && (
<span className="ml-auto text-xs font-normal text-[var(--color-text-tertiary)]">
@@ -41,7 +45,11 @@ export function CollapsibleSection({
</span>
)}
</button>
- {open ? <div className="space-y-3">{children}</div> : null}
+ {open ? (
+ <div id={bodyId} className="space-y-3">
+ {children}
+ </div>
+ ) : null}
</section>
);
}
diff --git a/packages/ui/src/shared/release-notice.tsx b/packages/ui/src/shared/release-notice.tsx
index ff43c9fa0..261fdede7 100644
--- a/packages/ui/src/shared/release-notice.tsx
+++ b/packages/ui/src/shared/release-notice.tsx
@@ -1,8 +1,7 @@
"use client";
import * as React from "react";
-import { Info, X } from "lucide-react";
-import { cn } from "../lib/cn";
+import { DismissibleNotice } from "./dismissible-notice";
const STORAGE_PREFIX = "repowise:release-notice-dismissed:";
@@ -14,21 +13,39 @@ export interface ReleaseNoticeProps {
/** The release this notice belongs to. Omit only if the notice is not tied
* to one, in which case dismissal is permanent. */
version?: string | null;
+ /** The one line the notice reads as. */
children: React.ReactNode;
+ /** The explanation, behind a "What changed" toggle on the same line. */
+ detail?: React.ReactNode;
+ /** The toggle's words, for hosts that localize. */
+ detailLabel?: string;
+ hideLabel?: string;
className?: string;
}
/**
* A one-time, dismissible "this changed in the release you just installed"
- * notice. Lives in the shared package so both the web app and hosted can show
+ * line. Lives in the shared package so both the web app and hosted can show
* it; the web app's `UpgradeBanner` does a different job (an upgrade is
* *available*) and is not what this replaces.
*
+ * One line, so it does not outrank the page it sits on; the explanation opens
+ * in place. The visual is the shared {@link DismissibleNotice}; this owns only
+ * whether the reader has dismissed it.
+ *
* Dismissal is best-effort `localStorage`: blocked site data leaves the notice
* showing rather than throwing, which is the right failure for something whose
* purpose is to be read once.
*/
-export function ReleaseNotice({ id, version, children, className }: ReleaseNoticeProps) {
+export function ReleaseNotice({
+ id,
+ version,
+ children,
+ detail,
+ detailLabel = "What changed",
+ hideLabel = "Hide",
+ className,
+}: ReleaseNoticeProps) {
const storageKey = STORAGE_PREFIX + id + (version ? `:v${version}` : "");
// Start dismissed so it does not flash in before the stored answer is read.
const [dismissed, setDismissed] = React.useState(true);
@@ -54,27 +71,21 @@ export function ReleaseNotice({ id, version, children, className }: ReleaseNotic
};
return (
- <div
- role="status"
- className={cn(
- "flex items-start gap-3 rounded-md border border-[var(--color-border-default)]",
- "bg-[var(--color-bg-elevated)] px-4 py-3 text-sm",
- className,
+ <DismissibleNotice onDismiss={dismiss} {...(className ? { className } : {})}>
+ {detail ? (
+ <details className="group/release">
+ <summary className="cursor-pointer list-none rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]">
+ {children}{" "}
+ <span className="text-[var(--color-accent-primary)] underline-offset-2 hover:underline">
+ <span className="group-open/release:hidden">{detailLabel}</span>
+ <span className="hidden group-open/release:inline">{hideLabel}</span>
+ </span>
+ </summary>
+ <div className="mt-1.5">{detail}</div>
+ </details>
+ ) : (
+ children
)}
- >
- <Info
- className="mt-0.5 h-4 w-4 shrink-0 text-[var(--color-text-tertiary)]"
- aria-hidden="true"
- />
- <div className="flex-1 text-[var(--color-text-secondary)]">{children}</div>
- <button
- type="button"
- onClick={dismiss}
- aria-label="Dismiss"
- className="rounded p-1 text-[var(--color-text-tertiary)] hover:bg-[var(--color-bg-wash-hover)] hover:text-[var(--color-text-primary)]"
- >
- <X className="h-4 w-4" />
- </button>
- </div>
+ </DismissibleNotice>
);
}
diff --git a/packages/web/messages/en.json b/packages/web/messages/en.json
index 1290b4caa..201a49539 100644
--- a/packages/web/messages/en.json
+++ b/packages/web/messages/en.json
@@ -255,6 +255,8 @@
"notIndexed": "Not indexed yet",
"snapshots": "{count, plural, one {# snapshot} other {# snapshots}}",
"coChangeNoticeTitle": "Health scores changed in this release.",
+ "coChangeNoticeMore": "What changed",
+ "coChangeNoticeLess": "Hide",
"coChangeNoticeBody": "Co-change coupling is now measured relative to your repository and decays with commit history rather than calendar time, so roughly one file in ten moves a band. Scores are not comparable to snapshots taken before this release.",
"tabs": {
"triage": "Overview",
diff --git a/packages/web/messages/zh-CN.json b/packages/web/messages/zh-CN.json
index 895bdbe5f..027aa13bb 100644
--- a/packages/web/messages/zh-CN.json
+++ b/packages/web/messages/zh-CN.json
@@ -255,6 +255,8 @@
"notIndexed": "尚未索引",
"snapshots": "{count} 个快照",
"coChangeNoticeTitle": "本次发布中健康分数发生了变化。",
+ "coChangeNoticeMore": "有哪些变化",
+ "coChangeNoticeLess": "收起",
"coChangeNoticeBody": "共变耦合现在相对你的仓库来度量,并随提交历史衰减,而不是按日历时间衰减,因此大约每十个文件中就有一个会跨越档位。分数与此前发布所取的快照不可比。",
"tabs": {
"triage": "总览",
diff --git a/packages/web/src/app/repos/[id]/code-health/page.tsx b/packages/web/src/app/repos/[id]/code-health/page.tsx
index 6ef4384c2..7aeef793a 100644
--- a/packages/web/src/app/repos/[id]/code-health/page.tsx
+++ b/packages/web/src/app/repos/[id]/code-health/page.tsx
@@ -544,11 +544,14 @@ export default function CodeHealthPage() {
>
{/* Replaced each release that moves health scores, and keyed with that
release's version so a reader who dismissed an earlier one sees it. */}
- <ReleaseNotice id="health-scoring" version="0.55.0">
- <span className="font-medium text-[var(--color-text-primary)]">
- {t("coChangeNoticeTitle")}
- </span>{" "}
- {t("coChangeNoticeBody")}
+ <ReleaseNotice
+ id="health-scoring"
+ version="0.55.0"
+ detail={t("coChangeNoticeBody")}
+ detailLabel={t("coChangeNoticeMore")}
+ hideLabel={t("coChangeNoticeLess")}
+ >
+ {t("coChangeNoticeTitle")}
</ReleaseNotice>
{meta ? (
diff --git a/packages/web/src/app/repos/[id]/refactoring/page.tsx b/packages/web/src/app/repos/[id]/refactoring/page.tsx
index 64c372567..45ba6b5be 100644
--- a/packages/web/src/app/repos/[id]/refactoring/page.tsx
+++ b/packages/web/src/app/repos/[id]/refactoring/page.tsx
@@ -312,6 +312,7 @@ export default function RefactoringPage({ params }: { params: Promise<{ id: stri
<RefactoringBoard
opportunities={opportunities}
summary={summary}
+ facets={data?.facets}
structuralOpportunities={structural?.items}
serverState={serverState}
onServerStateChange={(change) => {