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): quiet the findings cards to hairline outlines with a ghost agent prompt (#4164)

Raghav Chamadiyad0132ea970bc
diff --git a/packages/ui/__tests__/health/findings-view-queue.test.tsx b/packages/ui/__tests__/health/findings-view-queue.test.tsx
index 3fd000b51..92155ea62 100644
--- a/packages/ui/__tests__/health/findings-view-queue.test.tsx
+++ b/packages/ui/__tests__/health/findings-view-queue.test.tsx
@@ -157,9 +157,9 @@ describe("FindingsView graph", () => {
fireEvent.click(document.querySelector('[data-file="b.py"]')!);
const card = document.querySelector('[data-health-work-item="b.py"]')!;
- await waitFor(() => expect(card.className).toContain("border-[var(--color-accent-primary)]"));
- expect(document.querySelector('[data-health-work-item="a.py"]')!.className).not.toContain(
- "border-[var(--color-accent-primary)]",
+ await waitFor(() => expect(card).toHaveAttribute("data-highlighted", "true"));
+ expect(document.querySelector('[data-health-work-item="a.py"]')).not.toHaveAttribute(
+ "data-highlighted",
);
});
diff --git a/packages/ui/__tests__/health/refactoring-card.test.tsx b/packages/ui/__tests__/health/refactoring-card.test.tsx
index 42c1a850a..c29dbc079 100644
--- a/packages/ui/__tests__/health/refactoring-card.test.tsx
+++ b/packages/ui/__tests__/health/refactoring-card.test.tsx
@@ -1,6 +1,7 @@
import { describe, it, expect, vi } from "vitest";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { EFFORT_LABEL } from "../../src/health/labels";
+import { AGENT_PROMPT_LABEL } from "../../src/health/ai-prompt-action";
import {
RefactoringCard,
type RefactoringTarget,
@@ -138,29 +139,42 @@ describe("a file led by a history marker", () => {
);
expect(screen.getByText("Watch")).toBeInTheDocument();
expect(screen.getByText(/Editing the file will not clear it/)).toBeInTheDocument();
- expect(screen.queryByText("AI fix prompt")).not.toBeInTheDocument();
+ expect(screen.queryByText(AGENT_PROMPT_LABEL)).not.toBeInTheDocument();
});
it("keeps the fix prompt for a code-shape lead", () => {
render(<RefactoringCard target={target()} onGeneratePrompt={vi.fn()} />);
- expect(screen.getByText("AI fix prompt")).toBeInTheDocument();
+ expect(screen.getByText(AGENT_PROMPT_LABEL)).toBeInTheDocument();
expect(screen.queryByText("Watch")).not.toBeInTheDocument();
});
});
describe("the row's labels and action", () => {
- it("uses the shared effort wording in the badge and summary", () => {
+ it("uses the shared effort wording on the meta line", () => {
const original = EFFORT_LABEL.M;
EFFORT_LABEL.M = "Moderate";
try {
render(<RefactoringCard target={target({ effort_bucket: "M" })} />);
- expect(screen.getByTitle("Effort: Moderate (NLOC 900)")).toBeInTheDocument();
- expect(screen.getByText("· Moderate effort")).toBeInTheDocument();
+ expect(screen.getByText("Moderate effort")).toBeInTheDocument();
} finally {
EFFORT_LABEL.M = original;
}
});
+ it("keeps score, effort and findings on the line and the ranking behind a tip", () => {
+ render(<RefactoringCard target={target()} />);
+ expect(screen.getByText("Score 1.0/10")).toBeInTheDocument();
+ expect(screen.getByText("3 findings")).toBeInTheDocument();
+ expect(screen.queryByText(/leverage/i)).not.toBeInTheDocument();
+ expect(screen.queryByText(/NLOC/)).not.toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "How this file ranks" })).toBeInTheDocument();
+ });
+
+ it("prints the path once, name first", () => {
+ const { container } = render(<RefactoringCard target={target()} />);
+ expect(container.querySelectorAll("[data-path]")).toHaveLength(1);
+ });
+
it("labels a test file, and only a test file", () => {
const { rerender } = render(<RefactoringCard target={target({ is_test: true })} />);
expect(screen.getByText("test")).toBeInTheDocument();
diff --git a/packages/ui/src/health/fix-first/fix-first-item.tsx b/packages/ui/src/health/fix-first/fix-first-item.tsx
index f16eea282..cb649fa66 100644
--- a/packages/ui/src/health/fix-first/fix-first-item.tsx
+++ b/packages/ui/src/health/fix-first/fix-first-item.tsx
@@ -21,6 +21,7 @@ import { HighlightedCodeBlock } from "../../shared/code-block";
import { CommandLine } from "../../shared/command-line";
import { PlaceholderHint } from "../../refactoring/placeholder-hint";
import { AiPromptButton } from "../ai-prompt-button";
+import { AGENT_PROMPT_LABEL } from "../ai-prompt-action";
import { CONFIDENCE_LABEL, EFFORT_LABEL, STATUS_LABEL } from "../labels";
import { TIER_LABEL, fixLocation, fixPlanLabel, tierReason } from "./scope";
@@ -355,7 +356,7 @@ function Actions({
</Link>
) : null}
{onAiPrompt ? (
- <AiPromptButton label="Copy prompt for an agent" onClick={() => onAiPrompt(item)} />
+ <AiPromptButton label={AGENT_PROMPT_LABEL} onClick={() => onAiPrompt(item)} />
) : null}
</div>
{onTriage && findings > 0 ? (
diff --git a/packages/ui/src/health/refactoring-card.tsx b/packages/ui/src/health/refactoring-card.tsx
index fa126ae15..bf49bf6be 100644
--- a/packages/ui/src/health/refactoring-card.tsx
+++ b/packages/ui/src/health/refactoring-card.tsx
@@ -1,7 +1,7 @@
"use client";
import { useState } from "react";
-import { ArrowUpRight, ChevronDown, ChevronRight, Sparkles } from "lucide-react";
+import { ArrowUpRight, ChevronDown, ChevronRight } from "lucide-react";
import { InfoTip } from "../shared/info-tip";
import { FilePath } from "../shared/file-path";
import {
@@ -12,7 +12,7 @@ import {
isWatchOnlyBiomarker,
} from "./biomarker-glossary";
import type { BiomarkerDetailsRecord } from "./biomarker-details";
-import { EFFORT_TINT, type Severity } from "./tokens";
+import type { Severity } from "./tokens";
import { EFFORT_LABEL } from "./labels";
import { ImpactFigure } from "./impact-figure";
import { FindingOpportunityLink } from "./file-opportunity";
@@ -22,6 +22,11 @@ import { SeverityMark } from "./severity-mark";
import { VerificationTag } from "./verification-tag";
import { LowerPriorityTag } from "./lower-priority-tag";
import { PreviewBadge } from "./preview-badge";
+import { AiPromptButton } from "./ai-prompt-button";
+import { AGENT_PROMPT_LABEL } from "./ai-prompt-action";
+import { cn } from "../lib/cn";
+
+const MICRO = "font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]";
export type EffortBucket = "S" | "M" | "L" | "XL";
@@ -164,11 +169,13 @@ export function HealthWorkItemCard({
return (
<div
data-health-work-item={target.file_path}
- className={`rounded-lg border bg-[var(--color-bg-surface)] overflow-hidden transition-colors ${
+ data-highlighted={highlighted || undefined}
+ className={cn(
+ "overflow-hidden rounded-lg border bg-transparent transition-colors",
highlighted
- ? "border-[var(--color-accent-primary)] ring-1 ring-[var(--color-accent-primary)]/40"
- : "border-[var(--color-border-default)]"
- }`}
+ ? "border-[var(--color-border-hover)] ring-1 ring-[var(--color-accent-primary)]/40"
+ : "border-[var(--color-border-default)] hover:border-[var(--color-border-hover)] focus-within:border-[var(--color-border-hover)]",
+ )}
>
<div className="p-4 space-y-2">
<div className="flex items-center gap-2 flex-wrap">
@@ -182,13 +189,11 @@ export function HealthWorkItemCard({
/>
) : null}
{watch ? (
- <span className="font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- {HISTORY_LABEL}
- </span>
+ <span className={MICRO}>{HISTORY_LABEL}</span>
) : (
<SeverityMark severity={target.primary_severity} />
)}
- <span className="inline-flex items-center gap-1 text-xs font-semibold text-[var(--color-text-primary)]">
+ <span className="inline-flex items-center gap-1 text-xs font-medium text-[var(--color-text-primary)]">
{biomarkerLabel(target.primary_biomarker)}
{biomarkerInfo(target.primary_biomarker).description ? (
<InfoTip
@@ -198,25 +203,10 @@ export function HealthWorkItemCard({
) : null}
</span>
{target.module ? (
- <span className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)] rounded px-1.5 py-0.5 border border-[var(--color-border-default)]">
- {target.module}
- </span>
- ) : null}
- {target.is_test ? (
- <span className="font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- test
- </span>
+ <span className="text-xs text-[var(--color-text-tertiary)]">{target.module}</span>
) : null}
+ {target.is_test ? <span className={MICRO}>test</span> : null}
<PreviewBadge note={target.preview} />
- <span
- className={`inline-block rounded px-1.5 py-0.5 text-[10px] uppercase font-semibold ${EFFORT_TINT[target.effort_bucket]}`}
- title={`Effort: ${EFFORT_LABEL[target.effort_bucket]} (NLOC ${target.nloc})`}
- >
- {target.effort_bucket}
- </span>
- <span className="ml-auto text-xs tabular-nums text-[var(--color-error)]" title="Total health impact across this file's findings">
- −{target.total_impact.toFixed(2)}
- </span>
<AskAboutThis
context={{
kind: "health",
@@ -230,18 +220,19 @@ export function HealthWorkItemCard({
: `Explain the ${biomarkerLabel(target.primary_biomarker)} finding in ${target.file_path} and propose a safe way to address it.`
}
label={`Ask about the finding in ${target.file_path}`}
- className="-my-1 h-6 w-6"
+ className="-my-1 ml-auto h-6 w-6"
/>
</div>
<button
type="button"
data-work-item-header=""
onClick={onSelect ? () => onSelect(target) : undefined}
- className="group/file flex w-full items-center gap-1.5 text-left rounded-md -mx-1 px-1 py-0.5 hover:bg-[var(--color-bg-elevated)] disabled:cursor-default disabled:hover:bg-transparent"
+ className="group/file flex w-full items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] disabled:cursor-default"
disabled={!onSelect}
title={onSelect ? "Open file health drawer" : undefined}
>
- <p className="flex min-w-0 flex-1 items-baseline font-mono text-sm text-[var(--color-text-primary)] group-hover/file:text-[var(--color-accent-primary)]">
+ {/* The path once, name first; the symbol after it in the same mono. */}
+ <p className="flex min-w-0 flex-1 items-baseline font-mono text-sm text-[var(--color-text-primary)]">
<FilePath path={target.file_path} fold className="text-sm" />
{target.primary_function ? (
<span className="min-w-0 truncate whitespace-pre text-[var(--color-text-secondary)]">
@@ -251,51 +242,32 @@ export function HealthWorkItemCard({
) : null}
</p>
{onSelect ? (
- <ArrowUpRight className="h-3.5 w-3.5 shrink-0 text-[var(--color-text-tertiary)] group-hover/file:text-[var(--color-accent-primary)] transition-transform group-hover/file:-translate-y-px group-hover/file:translate-x-px" />
+ <ArrowUpRight className="h-3.5 w-3.5 shrink-0 text-[var(--color-text-tertiary)] transition-transform group-hover/file:-translate-y-px group-hover/file:translate-x-px group-hover/file:text-[var(--color-text-secondary)] group-focus-visible/file:text-[var(--color-text-secondary)]" />
) : null}
</button>
<p className="text-xs text-[var(--color-text-secondary)] line-clamp-2">{target.primary_reason}</p>
{/* The action comes from core, per marker; the card never writes one. */}
{target.primary_suggestion ? (
- <p className="text-xs text-[var(--color-text-primary)] line-clamp-3">
- <span className="mr-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
- Action
- </span>
+ <p className="text-xs text-[var(--color-text-secondary)] line-clamp-3">
+ <span className={cn(MICRO, "mr-1.5")}>Action</span>
{target.primary_suggestion}
</p>
) : null}
- <div className="flex items-center gap-3 pt-1 text-xs text-[var(--color-text-tertiary)] flex-wrap">
- <span>Score {target.score.toFixed(1)}/10</span>
- <span>· {target.nloc} NLOC</span>
- <span>· {EFFORT_LABEL[target.effort_bucket]} effort</span>
- <span>
- {"· "}
- {target.open_finding_count != null &&
- target.open_finding_count !== target.finding_count
- ? `${target.open_finding_count} open of ${target.finding_count} findings`
- : `${target.finding_count} findings`}
- </span>
- <span className="ml-auto tabular-nums">leverage {target.impact_per_effort.toFixed(2)}</span>
- </div>
{watch ? (
<p className="text-xs text-[var(--color-text-tertiary)]">{HISTORY_EXPLAINER}</p>
) : null}
- {onGeneratePrompt && !watch ? (
- <div className="pt-2">
- <button
- type="button"
- onClick={(e) => {
- e.stopPropagation();
- onGeneratePrompt(target);
- }}
- className="group/ai inline-flex items-center gap-1.5 rounded-md border border-[var(--color-model)]/40 bg-[var(--color-model-muted)] px-2.5 py-1 text-xs font-semibold text-[var(--color-model)] hover:bg-[var(--color-model)]/20 hover:border-[var(--color-model)]/60 transition-colors"
- title="Generate a ready-to-paste prompt for an AI coding agent"
- >
- <Sparkles className="h-3.5 w-3.5 transition-transform group-hover/ai:rotate-12" />
- AI fix prompt
- </button>
- </div>
- ) : null}
+ <div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1 pt-1">
+ <WorkItemMeta target={target} />
+ {onGeneratePrompt && !watch ? (
+ <AiPromptButton
+ variant="ghost"
+ label={AGENT_PROMPT_LABEL}
+ ariaLabel={`${AGENT_PROMPT_LABEL}: ${target.file_path}`}
+ onClick={() => onGeneratePrompt(target)}
+ className="-mr-2"
+ />
+ ) : null}
+ </div>
</div>
{expandable && hasFindings ? (
<>
@@ -303,7 +275,7 @@ export function HealthWorkItemCard({
type="button"
onClick={toggle}
aria-expanded={expanded}
- className="flex w-full items-center gap-2 px-4 py-2 text-xs text-[var(--color-text-secondary)] border-t border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)]"
+ className="flex w-full items-center gap-2 border-t border-[var(--color-border-default)] px-4 py-2 text-xs text-[var(--color-text-secondary)] transition-colors hover:text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-accent-primary)]"
>
{expanded ? <ChevronDown className="h-3.5 w-3.5" /> : <ChevronRight className="h-3.5 w-3.5" />}
{expanded ? "Hide" : "Show"} all {target.finding_count} findings
@@ -360,6 +332,31 @@ export type RefactoringTargetFinding = HealthWorkItemFinding;
export type RefactoringCardProps = HealthWorkItemCardProps;
export const RefactoringCard = HealthWorkItemCard;
+/**
+ * The decision facts on one quiet line: score, effort, how many findings.
+ * Impact, leverage and size order the list but do not decide a row, so they
+ * sit behind the tip.
+ */
+function WorkItemMeta({ target }: { target: HealthWorkItem }) {
+ const findings =
+ target.open_finding_count != null && target.open_finding_count !== target.finding_count
+ ? `${target.open_finding_count} open of ${target.finding_count} findings`
+ : `${target.finding_count} findings`;
+ return (
+ <p className="flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] tabular-nums text-[var(--color-text-tertiary)]">
+ <span>Score {target.score.toFixed(1)}/10</span>
+ <span aria-hidden>·</span>
+ <span>{EFFORT_LABEL[target.effort_bucket]} effort</span>
+ <span aria-hidden>·</span>
+ <span>{findings}</span>
+ <InfoTip
+ label="How this file ranks"
+ content={`Health impact −${target.total_impact.toFixed(2)} across its findings, over ${target.nloc} lines of code. Leverage ${target.impact_per_effort.toFixed(2)}: impact per unit of effort, which orders this list.`}
+ />
+ </p>
+ );
+}
+
/**
* Where a finding sits. Not a link: no file view renders a line anchor, so a
* "line 412" href would land at the top of the page every time. Silent
diff --git a/packages/ui/src/health/tokens.ts b/packages/ui/src/health/tokens.ts
index 88870befa..a32f2ec02 100644
--- a/packages/ui/src/health/tokens.ts
+++ b/packages/ui/src/health/tokens.ts
@@ -53,18 +53,6 @@ export const SEVERITY_SEGMENT: Record<Severity, string> = {
low: "var(--color-text-tertiary)",
};
-/**
- * Effort tint. A ramp, not a judgement: green is the cheap end, red the
- * expensive one. The badge prints the bucket letter beside it, so it belongs
- * on the semantic ramp. Here rather than in the card so it has one home.
- */
-export const EFFORT_TINT: Record<"S" | "M" | "L" | "XL", string> = {
- S: "bg-[var(--color-success)]/15 text-[var(--color-success)]",
- M: "bg-[var(--color-caution)]/15 text-[var(--color-caution)]",
- L: "bg-[var(--color-warning)]/15 text-[var(--color-warning)]",
- XL: "bg-[var(--color-error)]/15 text-[var(--color-error)]",
-};
-
/**
* The one health band -> colour vocabulary. Excellent and Good share the
* green; the band word carries the difference. Every table below is written
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.tsx
index b4118bcbf..d356906af 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
@@ -145,7 +145,7 @@ describe("FixFirstSection", () => {
getFixFirstItemPrompt.mockResolvedValue({ flavor: "generic", text: "Core prompt text" });
renderSection();
fireEvent.click(await screen.findByRole("button", { name: /Extract lines 60-122/ }));
- fireEvent.click(screen.getAllByRole("button", { name: "Copy prompt for an agent" })[0]!);
+ fireEvent.click(screen.getAllByRole("button", { name: "Copy prompt for your agent" })[0]!);
expect(await screen.findByText("Core prompt text")).toBeTruthy();
expect(getFixFirstItemPrompt).toHaveBeenCalledWith("r1", "fix1_a", {
flavor: expect.any(String),