Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(ui): open the stored plan from a plan-led Fix first finding (#3662)
Imaduddin Bhaisaheb236385ffb03b
diff --git a/packages/ui/__tests__/health/fix-first.test.tsx b/packages/ui/__tests__/health/fix-first.test.tsxindex 49f7269f4..4ee5ebc51 100644--- a/packages/ui/__tests__/health/fix-first.test.tsx+++ b/packages/ui/__tests__/health/fix-first.test.tsx@@ -184,6 +184,10 @@ describe("Fix first items", () => {expect(fixPlanLabel(REFACTOR)).toBe("Open the refactoring plan");expect(fixPlanLabel(PERF)).toBe("Open the performance fix");expect(fixPlanLabel(FINDING)).toBeNull();+ expect(fixPlanLabel({ kind: "finding", source: { ...FINDING.source, plan_ids: [] } })).toBeNull();+ expect(fixPlanLabel({ kind: "finding", source: { ...FINDING.source, plan_ids: ["refac2_big"] } })).toBe(+ "Open the refactoring plan",+ );renderList();openRow(REFACTOR);expect(screen.getByRole("link", { name: "Open the refactoring plan" }).getAttribute("href")).toBe(diff --git a/packages/ui/src/health/fix-first/scope.ts b/packages/ui/src/health/fix-first/scope.tsindex 9eea160fe..d842ac046 100644--- a/packages/ui/src/health/fix-first/scope.ts+++ b/packages/ui/src/health/fix-first/scope.ts@@ -132,9 +132,16 @@ export function fixLocation(item: Pick<FixItem, "target">): string {return line_start ? `${file_path}:${line_start}` : file_path;}-/** What "Open plan" opens, named for the unit it lands on; null for a finding. */-export function fixPlanLabel(item: Pick<FixItem, "kind">): string | null {+/**+ * What "Open plan" opens, named for the unit it lands on. A finding gets one+ * only when it leads with a stored plan (`source.plan_ids` non-empty); a bare+ * finding has nothing to open, so null.+ */+export function fixPlanLabel(item: Pick<FixItem, "kind" | "source">): string | null {if (item.kind === "refactor") return `Open the ${WORK_UNIT_LABEL.refactor}`;if (item.kind === "perf_fix") return `Open the ${WORK_UNIT_LABEL.perf_fix}`;+ if (item.kind === "finding" && item.source.plan_ids.length > 0) {+ return `Open the ${WORK_UNIT_LABEL.refactor}`;+ }return null;}diff --git a/packages/web/src/components/code-health/fix-first-section.test.tsx b/packages/web/src/components/code-health/fix-first-section.test.tsxindex 159bb90cc..c9c2d7601 100644--- a/packages/web/src/components/code-health/fix-first-section.test.tsx+++ b/packages/web/src/components/code-health/fix-first-section.test.tsx@@ -107,6 +107,14 @@ describe("fixPlanHref", () => {fixPlanHref("r1", item({ kind: "finding", source: { opportunity_id: null, plan_ids: [], finding_ids: ["f"] } })),).toBeNull();});+ it("opens the stored plan of a plan-led finding by id, and offers nothing without one", () => {+ expect(+ fixPlanHref("r1", item({ kind: "finding", source: { opportunity_id: null, plan_ids: ["refac2_big", "refac2_b"], finding_ids: ["f"] } })),+ ).toBe("/repos/r1/refactoring?plan=refac2_big");+ expect(+ fixPlanHref("r1", item({ kind: "finding", source: { opportunity_id: null, plan_ids: ["a/b c"], finding_ids: ["f"] } })),+ ).toBe("/repos/r1/refactoring?plan=a%2Fb%20c");+ });});describe("FixFirstSection", () => {diff --git a/packages/web/src/components/code-health/fix-first-section.tsx b/packages/web/src/components/code-health/fix-first-section.tsxindex ca837b1e7..9f6ff9df3 100644--- a/packages/web/src/components/code-health/fix-first-section.tsx+++ b/packages/web/src/components/code-health/fix-first-section.tsx@@ -19,6 +19,10 @@ import { getFixFirst, getFixFirstItemPrompt, updateFindingStatus } from "@/lib/aconst LIMIT = 10;export function fixPlanHref(repoId: string, item: FixItem): string | null {+ const planId = item.source.plan_ids[0];+ if (item.kind === "finding" && planId) {+ return `/repos/${repoId}/refactoring?plan=${encodeURIComponent(planId)}`;+ }const id = item.source.opportunity_id;if (!id) return null;const opp = encodeURIComponent(id);