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(health): separate all-clear, not-yet, filtered and error states across code health tabs (#3308)
Raghav Chamadiya7ba7defd41c1
diff --git a/packages/ui/__tests__/health/fix-first.test.tsx b/packages/ui/__tests__/health/fix-first.test.tsxindex 8c5ab2f34..8b0ec8002 100644--- a/packages/ui/__tests__/health/fix-first.test.tsx+++ b/packages/ui/__tests__/health/fix-first.test.tsx@@ -172,26 +172,27 @@ describe("Fix first items", () => {expect(screen.getAllByRole("button", { name: "Acknowledged" }).length).toBe(1);});- it("says why nothing is listed when the queue is empty", () => {- renderList({- queue: { ...FIX_FIRST_QUEUE, items: [], lead: null, totals: { ...FIX_FIRST_QUEUE.totals, shown: 0 } },+ it("separates excluded-by-rule, no analysis and all clear when the queue is empty", () => {+ const empty = { ...FIX_FIRST_QUEUE, items: [], lead: null };+ const { unmount } = renderList({+ queue: { ...empty, totals: { ...empty.totals, shown: 0 } },});- expect(screen.getByText(/Nothing eligible to fix first/)).toBeTruthy();- });-});--describe("Fix first agent prompt", () => {- it("is offered only when the host can load it", () => {- renderList();- expect(screen.queryByRole("button", { name: "Copy prompt for an agent" })).toBeNull();- });+ expect(screen.getByText("Everything was left out by a rule")).toBeTruthy();+ unmount();++ const noExclusions = Object.fromEntries(+ Object.keys(empty.totals.excluded).map((k) => [k, 0]),+ ) as typeof empty.totals.excluded;+ const none = { ...empty, totals: { ...empty.totals, shown: 0, excluded: noExclusions } };+ const second = renderList({+ queue: { ...none, basis: { analyzed_commit: null, health_analyzed_at: null } },+ });+ expect(screen.getByText("Health has not been analyzed yet")).toBeTruthy();+ second.unmount();- it("shows the prompt the host loads for the item", async () => {- const loadPrompt = vi.fn().mockResolvedValue("Prompt from core");- renderList({ loadPrompt });- openRow(REFACTOR);- fireEvent.click(screen.getByRole("button", { name: "Copy prompt for an agent" }));- expect(await screen.findByText("Prompt from core")).toBeTruthy();- expect(loadPrompt).toHaveBeenCalledWith(REFACTOR, expect.any(String));+ renderList({+ queue: { ...none, basis: { analyzed_commit: "abc", health_analyzed_at: "2026-10-01" } },+ });+ expect(screen.getByText("Nothing to fix first")).toBeTruthy();});});diff --git a/packages/ui/src/health/biomarker-glossary.ts b/packages/ui/src/health/biomarker-glossary.tsindex 7a3de223d..bfb803ed7 100644--- a/packages/ui/src/health/biomarker-glossary.ts+++ b/packages/ui/src/health/biomarker-glossary.ts@@ -492,7 +492,7 @@ export const DIMENSION_LABEL: Record<BiomarkerDimension, string> = {/** Tailwind chip classes per pillar, matching the surrounding chip palette. */export const DIMENSION_CHIP: Record<BiomarkerDimension, string> = {- defect: "bg-[var(--color-accent-primary)]/10 text-[var(--color-accent-primary)]",+ defect: "bg-[var(--color-bg-elevated)] text-[var(--color-text-secondary)]",maintainability: "bg-[var(--color-accent-secondary)]/10 text-[var(--color-accent-secondary)]",performance: "bg-[var(--color-info)]/10 text-[var(--color-info)]",// Deliberately the most muted chip in the palette: an advisory finding costsdiff --git a/packages/ui/src/health/biomarker-list.tsx b/packages/ui/src/health/biomarker-list.tsxindex 8a85fe955..4934138a9 100644--- a/packages/ui/src/health/biomarker-list.tsx+++ b/packages/ui/src/health/biomarker-list.tsx@@ -2,6 +2,7 @@import { useState } from "react";import { ChevronDown, ChevronRight } from "lucide-react";+import { EmptyState } from "../shared/empty-state";import { InfoTip } from "../shared/info-tip";import {biomarkerLabel,@@ -96,9 +97,10 @@ export function BiomarkerList({if (filtered.length === 0) {return (- <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-6 text-sm text-[var(--color-text-secondary)]">- No marker findings match the current filters.- </div>+ <EmptyState+ {...(findings.length > 0 ? { tone: "filtered" as const } : {})}+ title={findings.length > 0 ? "No marker findings match these filters" : "No marker findings"}+ />);}diff --git a/packages/ui/src/health/code-health-controls.tsx b/packages/ui/src/health/code-health-controls.tsxindex 1a58e3253..0452a84fe 100644--- a/packages/ui/src/health/code-health-controls.tsx+++ b/packages/ui/src/health/code-health-controls.tsx@@ -54,7 +54,7 @@ export function FilterChip({className={cn("text-xs rounded-md px-2 py-1 border transition-colors",active- ? "bg-[var(--color-accent-muted)] text-[var(--color-accent-primary)] border-[var(--color-accent-primary)]/50"+ ? "bg-[var(--color-bg-selected)] text-[var(--color-text-primary)] border-[var(--color-border-hover)]": "border-[var(--color-border-default)] text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:border-[var(--color-border-hover)]",)}>diff --git a/packages/ui/src/health/code-health-map.tsx b/packages/ui/src/health/code-health-map.tsxindex 1b1bebc3b..6ca6ea759 100644--- a/packages/ui/src/health/code-health-map.tsx+++ b/packages/ui/src/health/code-health-map.tsx@@ -20,6 +20,7 @@ import type {MouseEvent as ReactMouseEvent,} from "react";+import { EmptyState } from "../shared/empty-state";import { useCommunityFamilies } from "../shared/use-theme-tokens";import { HEALTH_UNSUPPORTED_NOTICE, OVERLAY_ORDER, OVERLAY_SPECS, noFileScored } from "./map/lens";import { packGalaxies, rand } from "./map/layout";@@ -338,10 +339,14 @@ export function CodeHealthMap({return (<divref={containerRef}- className="flex w-full items-center justify-center rounded-xl border border-dashed border-[var(--color-border-default)] bg-[var(--color-bg-root)] text-sm text-[var(--color-text-tertiary)]"+ className="flex w-full items-center justify-center"style={{ minHeight }}>- No files to map yet. Index this repo to populate health.+ <EmptyState+ size="compact"+ title="No files to map yet"+ description="Index this repo to populate health."+ /></div>);}diff --git a/packages/ui/src/health/coverage-view.tsx b/packages/ui/src/health/coverage-view.tsxindex 51b87b59a..0899891dd 100644--- a/packages/ui/src/health/coverage-view.tsx+++ b/packages/ui/src/health/coverage-view.tsx@@ -32,6 +32,8 @@ import type {import { Skeleton } from "../ui/skeleton";import { EmptyState } from "../shared/empty-state";+import { ApiError } from "../shared/api-error";+import { toFriendlyMessage } from "../lib/errors";import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";import { ResultsFooter } from "../shared/results-footer";import { OverviewSection } from "../overview/section";@@ -67,7 +69,7 @@ import type { CodeHealthAdapter } from "./code-health-adapter";export function CoverageView({ adapter }: { adapter: CodeHealthAdapter }) {const [promptRow, setPromptRow] = useState<CoverageFilePromptInput | null>(null);- const { data, isLoading, error } = useSWR<HealthCoverageResponse>(+ const { data, isLoading, error, mutate } = useSWR<HealthCoverageResponse>(`code-health-coverage:${adapter.cacheKey}`,() => adapter.getCoverage({ limit: 5000 }),{ revalidateOnFocus: false },@@ -92,9 +94,10 @@ export function CoverageView({ adapter }: { adapter: CodeHealthAdapter }) {{isLoading ? (<CoverageSkeleton />) : error ? (- <EmptyState+ <ApiErrortitle="Couldn't load coverage data"- description="The coverage endpoint returned an error. Try refreshing, or re-run the health pass."+ message={toFriendlyMessage(error)}+ onRetry={() => void mutate()}/>) : data?.basis === "inferred" && data.inferred ? (// No report was ever ingested, and the graph can answer anyway. This@@ -452,10 +455,22 @@ function CoverageBody({stacked="sm"bareempty={- <EmptyState- title="No files match"- description="Adjust the path filter to see coverage rows."- />+ search ? (+ <EmptyState+ tone="filtered"+ title="No files match"+ description="Adjust the path filter to see coverage rows."+ action={{+ label: "Clear filters",+ onClick: () => {+ setSearch("");+ setVisible(PAGE);+ },+ }}+ />+ ) : (+ <EmptyState size="compact" title="No files to list" />+ )}/>{sortedFiles.length > 0 ? (@@ -552,10 +567,15 @@ function CoverageGap({stacked="sm"bareempty={- <EmptyState- title="Every file is reached"- description="The graph found a test that reaches every file the coverage report didn't name."- />+ map.files_total > 0 ? (+ <EmptyState+ tone="positive"+ title="Every file is reached"+ description="The graph found a test that reaches every file the coverage report didn't name."+ />+ ) : (+ <EmptyState size="compact" title="No other files to check" />+ )}/></div>diff --git a/packages/ui/src/health/file-signals-panel.tsx b/packages/ui/src/health/file-signals-panel.tsxindex d703b3ccf..2b2a717a6 100644--- a/packages/ui/src/health/file-signals-panel.tsx+++ b/packages/ui/src/health/file-signals-panel.tsx@@ -214,7 +214,7 @@ function Row({>{present ? value : "No signal"}{present && badge != null && (- <span className="rounded-full border border-[var(--color-accent-muted)] bg-[var(--color-accent-muted)] px-1.5 py-px text-[9px] font-medium uppercase tracking-wide text-[var(--color-accent-primary)]">+ <span className="rounded-full border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-1.5 py-px font-mono text-[10px] font-medium uppercase tracking-wide text-[var(--color-text-secondary)]">{badge}</span>)}diff --git a/packages/ui/src/health/file-trend-chart.tsx b/packages/ui/src/health/file-trend-chart.tsxindex b853fa5c2..464b0956d 100644--- a/packages/ui/src/health/file-trend-chart.tsx+++ b/packages/ui/src/health/file-trend-chart.tsx@@ -1,6 +1,7 @@"use client";import { TrendingDown } from "lucide-react";+import { EmptyState } from "../shared/empty-state";import type { FileHealthTrend } from "@repowise-dev/types/health";import { formatDate } from "../lib/format";import { deltaColor, formatDelta, scoreTextColor } from "./tokens";@@ -43,10 +44,11 @@ export function FileTrendChart({ trend, height = 140, bare = false }: FileTrendCconst body =points.length < 2 ? (- <div className="rounded-md border border-dashed border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4 text-center text-xs text-[var(--color-text-tertiary)]">- No score history yet. Trends appear once this file has been scored in at- least two <code>repowise</code> runs.- </div>+ <EmptyState+ size="compact"+ title="No score history yet"+ description="Trends appear once this file has been scored in at least two index runs."+ />) : (<><Chart points={points} height={height} />diff --git a/packages/ui/src/health/findings-view.tsx b/packages/ui/src/health/findings-view.tsxindex 51af2717d..29957735e 100644--- a/packages/ui/src/health/findings-view.tsx+++ b/packages/ui/src/health/findings-view.tsx@@ -26,6 +26,8 @@ import type {import { Skeleton } from "../ui/skeleton";import { Button } from "../ui/button";import { EmptyState } from "../shared/empty-state";+import { ApiError } from "../shared/api-error";+import { toFriendlyMessage } from "../lib/errors";import { AiPromptModal, fileChatContext } from "./ai-prompt-modal";import { HotFunctionsPanel } from "./hot-functions-panel";@@ -84,7 +86,11 @@ export function FindingsView({ adapter }: { adapter: CodeHealthAdapter }) {// the landing view already fired — no extra round-trip. Used to gate the// queue fetch and to seed the marker filter with the repo's whole// vocabulary rather than only the markers the current page happens to hold.- const { data: overview } = useSWR<HealthOverviewResponse>(+ const {+ data: overview,+ error: overviewError,+ mutate: mutateOverview,+ } = useSWR<HealthOverviewResponse>(`code-health-overview:${cacheKey}`,() => adapter.getOverview(25),{ revalidateOnFocus: false },@@ -267,6 +273,7 @@ export function FindingsView({ adapter }: { adapter: CodeHealthAdapter }) {data: queue,isLoading: queueLoading,isValidating: queueValidating,+ error: queueError,mutate: mutateQueue,} = useSWR<HealthWorkQueueResponse>(overview ? `code-health-queue:${cacheKey}:${JSON.stringify(query)}` : null,@@ -568,24 +575,49 @@ export function FindingsView({ adapter }: { adapter: CodeHealthAdapter }) {</div></div>- {queueLoading && !queue ? (+ {!overview ? (+ overviewError ? (+ <ApiError+ size="compact"+ title="Couldn't load findings"+ message={toFriendlyMessage(overviewError)}+ onRetry={() => void mutateOverview()}+ />+ ) : (+ <div className="grid gap-3">+ {Array.from({ length: 4 }).map((_, i) => (+ <Skeleton key={i} className="h-28 w-full" />+ ))}+ </div>+ )+ ) : queueLoading && !queue ? (<div className="grid gap-3">{Array.from({ length: 4 }).map((_, i) => (<Skeleton key={i} className="h-28 w-full" />))}</div>- ) : total === 0 ? (- <EmptyState- title={filtered ? "Nothing matches these filters" : "No open findings"}- description={- filtered- ? "This view lists files carrying findings, ranked by leverage. Widen a filter to see more."- : "Files carrying findings appear here, ranked by leverage. Sync the repo to pick up new work."- }- {...(filtered- ? { action: { label: "Clear filters", onClick: clearFilters } }- : {})}+ ) : queueError && !queue ? (+ <ApiError+ size="compact"+ title="Couldn't load findings"+ message={toFriendlyMessage(queueError)}+ onRetry={() => void mutateQueue()}/>+ ) : total === 0 ? (+ filtered ? (+ <EmptyState+ tone="filtered"+ title="Nothing matches these filters"+ description="This view lists files carrying findings, ranked by leverage. Widen a filter to see more."+ action={{ label: "Clear filters", onClick: clearFilters }}+ />+ ) : (+ <EmptyState+ tone="positive"+ title="No open findings"+ description={`Health was scored${overview.summary.file_count ? ` across ${overview.summary.file_count.toLocaleString()} files` : ""} and none carries an open finding. New work appears here after the next index update.`}+ />+ )) : (<divclassName={@@ -652,6 +684,7 @@ export function FindingsView({ adapter }: { adapter: CodeHealthAdapter }) {highlightedPath={highlightedPath}selectedPaths={selectedPaths}onToggleSelect={toggleSelect}+ onClearFilters={filtered ? clearFilters : undefined}/></section>))}diff --git a/packages/ui/src/health/fix-first/fix-first-list.tsx b/packages/ui/src/health/fix-first/fix-first-list.tsxindex 38c46da7e..2970b2bfc 100644--- a/packages/ui/src/health/fix-first/fix-first-list.tsx+++ b/packages/ui/src/health/fix-first/fix-first-list.tsx@@ -13,13 +13,14 @@ import type { FixFirstQueue, FixItem, FixScope } from "@repowise-dev/types/fix-fimport { Skeleton, SkeletonRegion } from "../../ui/skeleton";import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover";import { ApiError } from "../../shared/api-error";+import { EmptyState } from "../../shared/empty-state";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 { exclusionEntries, fixFirstScopeSentence, fixLocation } from "./scope";+import { exclusionEntries, exclusionPhrase, fixFirstScopeSentence, fixLocation } from "./scope";export interface FixFirstListProps {queue: FixFirstQueue | undefined;@@ -137,10 +138,7 @@ export function FixFirstList({<Skeleton className="h-20 w-full" /></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, or the index has- no health analysis yet.- </p>+ <FixFirstEmpty queue={queue} />) : queue ? (<ol className="flex flex-col divide-y divide-[var(--color-border-default)]">{queue.items.map((item) => (@@ -174,3 +172,33 @@ export function FixFirstList({</OverviewSection>);}++/** Nothing queued: all clear, left out by a rule, or never analyzed. Each says something different. */+function FixFirstEmpty({ queue }: { queue: FixFirstQueue }) {+ const excluded = exclusionPhrase(queue.totals.excluded);+ if (excluded) {+ return (+ <EmptyState+ size="compact"+ title="Everything was left out by a rule"+ description={`Nothing is queued because the rules above set aside ${excluded}.`}+ />+ );+ }+ if (!queue.basis.health_analyzed_at) {+ return (+ <EmptyState+ size="compact"+ title="Health has not been analyzed yet"+ description="Run an index update and the ranked list appears here."+ />+ );+ }+ return (+ <EmptyState+ tone="positive"+ title="Nothing to fix first"+ description="Health was analyzed and no function or finding is worth fixing ahead of the rest."+ />+ );+}diff --git a/packages/ui/src/health/map/inspector.tsx b/packages/ui/src/health/map/inspector.tsxindex 1180b7eea..dc37979ab 100644--- a/packages/ui/src/health/map/inspector.tsx+++ b/packages/ui/src/health/map/inspector.tsx@@ -132,7 +132,7 @@ export function MapFieldList({"flex w-full flex-col gap-0.5 px-1.5 py-2 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]",selected- ? "bg-[var(--color-accent-muted)]"+ ? "bg-[var(--color-bg-selected)] shadow-[inset_2px_0_0_var(--color-accent-primary)]": "hover:bg-[var(--color-bg-elevated)]",)}>diff --git a/packages/ui/src/health/performance/states.tsx b/packages/ui/src/health/performance/states.tsxindex 41759ae60..51f107585 100644--- a/packages/ui/src/health/performance/states.tsx+++ b/packages/ui/src/health/performance/states.tsx@@ -31,7 +31,7 @@ export function QueueSkeleton() {export function QueueError({ onRetry }: { onRetry?: (() => void) | undefined }) {return (<EmptyState- icon={<Gauge className="h-6 w-6" />}+ tone="error"title="Could not load performance opportunities"description="The repository may need indexing, or the server may be temporarily unavailable. Nothing here says the code is fast."{...(onRetry ? { action: { label: "Try again", onClick: onRetry } } : {})}@@ -43,7 +43,7 @@ export function QueueError({ onRetry }: { onRetry?: (() => void) | undefined })export function UnavailableQueue({ summary }: { summary: PerformanceOpportunitySummary }) {return (<EmptyState- icon={<Gauge className="h-6 w-6" />}+ icon={<Gauge />}title="This index has not been analyzed for performance"description={summary.detail ??@@ -57,36 +57,22 @@ export function UnavailableQueue({ summary }: { summary: PerformanceOpportunityS/** Analyzed, and nothing supported surfaced. Say exactly that. */export function EmptyQueue() {return (- <div className="border-t border-[var(--color-border-default)] px-1 py-12 text-center">- <h3 className="text-[15px] font-semibold text-[var(--color-text-primary)]">- No supported pattern surfaced- </h3>- <p className="mx-auto mt-2 max-w-[60ch] text-sm text-[var(--color-text-tertiary)]">- The detectors are high precision and low recall, so an empty queue means nothing they- recognize was found. It does not measure latency and does not claim the code is fast.- </p>- </div>+ <EmptyState+ tone="positive"+ title="No supported pattern surfaced"+ description="The detectors are high precision and low recall, so an empty queue means nothing they recognize was found. It does not measure latency and does not claim the code is fast."+ />);}export function FilteredEmpty({ onClear }: { onClear: () => void }) {return (- <div className="border-t border-[var(--color-border-default)] px-1 py-12 text-center">- <h3 className="text-[15px] font-semibold text-[var(--color-text-primary)]">- No opportunities match these filters- </h3>- <p className="mx-auto mt-2 max-w-[60ch] text-sm text-[var(--color-text-tertiary)]">- The counts beside each filter already account for the other active filters. This- combination may come from a restored view state that no longer matches the index.- </p>- <button- type="button"- onClick={onClear}- className="mt-4 rounded text-sm font-medium 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)]"- >- Clear filters- </button>- </div>+ <EmptyState+ tone="filtered"+ title="No opportunities match these filters"+ description="The counts beside each filter already account for the other active filters. This combination may come from a restored view state that no longer matches the index."+ action={{ label: "Clear filters", onClick: onClear }}+ />);}diff --git a/packages/ui/src/health/refactoring-card.tsx b/packages/ui/src/health/refactoring-card.tsxindex 224f632a0..a2eb8f42a 100644--- a/packages/ui/src/health/refactoring-card.tsx+++ b/packages/ui/src/health/refactoring-card.tsx@@ -388,7 +388,7 @@ function StatusButton({onClick={onClick}className={`text-[10px] rounded px-1.5 py-0.5 border transition-colors ${isActive- ? "bg-[var(--color-accent-muted)] text-[var(--color-accent-primary)] border-[var(--color-accent-primary)]/50"+ ? "bg-[var(--color-bg-selected)] text-[var(--color-text-primary)] border-[var(--color-border-hover)]": "border-[var(--color-border-default)] text-[var(--color-text-tertiary)] hover:text-[var(--color-text-primary)] hover:border-[var(--color-border-hover)]"}`}>diff --git a/packages/ui/src/health/refactoring-target-list.tsx b/packages/ui/src/health/refactoring-target-list.tsxindex afd15862e..9e09a95e7 100644--- a/packages/ui/src/health/refactoring-target-list.tsx+++ b/packages/ui/src/health/refactoring-target-list.tsx@@ -1,5 +1,6 @@"use client";+import { EmptyState } from "../shared/empty-state";import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";import type { RefactoringOpportunity } from "@repowise-dev/types/refactoring";import {@@ -32,6 +33,8 @@ export interface HealthWorkQueueListProps {| undefined;refactoringOpportunityHref?: ((opportunityId: string) => string) | undefined;emptyMessage?: string;+ /** Wired to the host's filter reset; shows a Clear filters action when set. */+ onClearFilters?: (() => void) | undefined;/** File path of the card to flash-highlight (quadrant click). */highlightedPath?: string | null | undefined;/** Bulk triage selection, by file path. */@@ -47,7 +50,8 @@ export function HealthWorkQueueList({onLoadFindings,onLoadOpportunity,refactoringOpportunityHref,- emptyMessage = "No health work items match the current filters.",+ emptyMessage = "No health work items match these filters",+ onClearFilters,highlightedPath,selectedPaths,onToggleSelect,@@ -93,9 +97,11 @@ export function HealthWorkQueueList({if (targets.length === 0) {return (- <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-6 text-sm text-[var(--color-text-secondary)]">- {emptyMessage}- </div>+ <EmptyState+ tone="filtered"+ title={emptyMessage}+ {...(onClearFilters ? { action: { label: "Clear filters", onClick: onClearFilters } } : {})}+ />);}const remaining = targets.length - shown;diff --git a/packages/ui/src/health/trend-chart.tsx b/packages/ui/src/health/trend-chart.tsxindex 702e9c27f..abc08b240 100644--- a/packages/ui/src/health/trend-chart.tsx+++ b/packages/ui/src/health/trend-chart.tsx@@ -1,5 +1,6 @@"use client";+import { EmptyState } from "../shared/empty-state";import { formatDate } from "../lib/format";export interface TrendSeriesPoint {@@ -53,10 +54,11 @@ function runs<T>(items: T[], has: (item: T) => boolean): number[][] {export function TrendChart({ history, height = 220 }: TrendChartProps) {if (!history || history.length === 0) {return (- <p className="max-w-[62ch] text-sm text-[var(--color-text-secondary)]">- No snapshots yet. Each index or sync records one; the trend appears from the- second snapshot on.- </p>+ <EmptyState+ size="compact"+ title="No snapshots yet"+ description="Each index update records one, and the trend appears from the second."+ />);}diff --git a/packages/ui/src/health/trend-view.tsx b/packages/ui/src/health/trend-view.tsxindex 8aa005ed4..cf130bc0a 100644--- a/packages/ui/src/health/trend-view.tsx+++ b/packages/ui/src/health/trend-view.tsx@@ -22,7 +22,10 @@ import { AlertTriangle, Info } from "lucide-react";import type { HealthCounts, HealthTrendResponse } from "@repowise-dev/types/health";import { formatScore } from "@repowise-dev/types/health";-import { Skeleton } from "../ui/skeleton";+import { Skeleton, SkeletonRegion } from "../ui/skeleton";+import { ApiError } from "../shared/api-error";+import { EmptyState } from "../shared/empty-state";+import { toFriendlyMessage } from "../lib/errors";import { StatRibbon, type RibbonStat } from "../stats/stat-ribbon";import { TrendChart } from "./trend-chart";@@ -66,20 +69,41 @@ export function TrendView({data,isLoading,error,+ onRetry,counts,}: {data: HealthTrendResponse | undefined;isLoading: boolean;error: unknown;+ onRetry?: (() => void) | undefined;/** What the page's figures count, so this section cannot claim the other reading. */counts?: HealthCounts;}) {- if (isLoading) return <Skeleton className="h-64 w-full rounded-lg" />;- if (error || !data) {+ if (isLoading) {return (- <p className="text-sm text-[var(--color-text-secondary)]">- Couldn't load trend data. Try refreshing.- </p>+ <SkeletonRegion className="flex flex-col gap-6" label="Loading trend">+ <Skeleton className="h-[72px] w-full" />+ <Skeleton className="h-[220px] w-full" />+ </SkeletonRegion>+ );+ }+ if (error) {+ return (+ <ApiError+ size="compact"+ title="Couldn't load trend data"+ message={toFriendlyMessage(error)}+ {...(onRetry ? { onRetry } : {})}+ />+ );+ }+ if (!data) {+ return (+ <EmptyState+ size="compact"+ title="No trend recorded yet"+ description="Each index update records a snapshot, and the trend appears from the second one."+ />);}@@ -168,8 +192,8 @@ export function TrendView({{singleSnapshot ? (<p className="max-w-[62ch] text-sm text-[var(--color-text-secondary)]">- One snapshot so far. The trend lines appear once a second one lands. Sync the- repo, or wait for the next automatic index, and this fills in.+ One snapshot so far. The trend lines appear once a second one lands, after the next+ index update.</p>) : (<TrendChart history={[...data.history].reverse()} />diff --git a/packages/web/src/app/repos/[id]/code-health/page.tsx b/packages/web/src/app/repos/[id]/code-health/page.tsxindex fc605bb01..130cb57f8 100644--- a/packages/web/src/app/repos/[id]/code-health/page.tsx+++ b/packages/web/src/app/repos/[id]/code-health/page.tsx@@ -319,6 +319,7 @@ export default function CodeHealthPage() {data: trend,isLoading: trendLoading,error: trendError,+ mutate: mutateTrend,} = useSWR<HealthTrendResponse>(`code-health-trend:${repoId}${scopeKey}`,() => getHealthTrend(repoId, 20, scope),@@ -601,6 +602,7 @@ export default function CodeHealthPage() {data={trend}isLoading={trendLoading}error={trendError}+ onRetry={() => void mutateTrend()}counts={counts}/></OverviewSection>