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): read repo health on the three bands beside a health mark (#4581)
Raghav Chamadiya5c582e489d99
diff --git a/packages/ui/__tests__/health/health-mark.test.ts b/packages/ui/__tests__/health/health-mark.test.tsnew file mode 100644index 000000000..bce329f62--- /dev/null+++ b/packages/ui/__tests__/health/health-mark.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from "vitest";+import { HEALTHY_MIN, NEEDS_WORK_MIN } from "@repowise-dev/types/health";+import { HEALTH_MARK_BANDS, healthMark } from "../../src/health/tokens";++describe("healthMark", () => {+ it("reads a score on the three bands, edges inclusive", () => {+ expect(healthMark(HEALTHY_MIN)).toMatchObject({ band: "healthy", label: "Healthy" });+ expect(healthMark(7.99)).toMatchObject({ band: "warning", label: "Warning" });+ expect(healthMark(NEEDS_WORK_MIN)).toMatchObject({ band: "warning" });+ expect(healthMark(3.99)).toMatchObject({ band: "alert", label: "Alert" });+ expect(healthMark(1)).toMatchObject({ band: "alert" });+ });++ it("floors the figure so it never prints across a band edge", () => {+ expect(healthMark(7.96)).toMatchObject({ value: "7.9", label: "Warning" });+ expect(healthMark(8.5)).toMatchObject({ value: "8.5", label: "Healthy" });+ });++ it("paints each band in its own semantic colour", () => {+ expect(healthMark(9).color).toBe("var(--color-success)");+ expect(healthMark(6).color).toBe("var(--color-warning)");+ expect(healthMark(2).color).toBe("var(--color-error)");+ });++ it("keys the bands on the shared cutoffs, top to bottom", () => {+ expect(HEALTH_MARK_BANDS.map((b) => b.min)).toEqual([HEALTHY_MIN, NEEDS_WORK_MIN, 0]);+ });+});diff --git a/packages/ui/__tests__/overview/repo-rows.test.tsx b/packages/ui/__tests__/overview/repo-rows.test.tsxindex 9b8f49a50..e6f9c506d 100644--- a/packages/ui/__tests__/overview/repo-rows.test.tsx+++ b/packages/ui/__tests__/overview/repo-rows.test.tsx@@ -63,33 +63,29 @@ describe("RepoRows", () => {expect(screen.getByText("—")).toBeTruthy();});- it("bands the score on the same ladder the repo pages use", () => {+ it("reads the score on the three bands of a health mark", () => {render(<RepoRowsrepos={[row({ id: "a", name: "alpha", health: 9.1 }),row({ id: "b", name: "beta", health: 7.4 }),- row({ id: "c", name: "gamma", health: 6.0 }),- row({ id: "d", name: "delta", health: 4.5 }),- row({ id: "e", name: "epsilon", health: 3.0 }),+ row({ id: "c", name: "gamma", health: 3.0 }),]}/>,);- expect(screen.getByText("Excellent")).toBeTruthy();- expect(screen.getByText("Good")).toBeTruthy();- expect(screen.getByText("Fair")).toBeTruthy();- expect(screen.getByText("Needs work")).toBeTruthy();- expect(screen.getByText("At risk")).toBeTruthy();+ expect(screen.getByText("Healthy")).toBeTruthy();+ expect(screen.getByText("Warning")).toBeTruthy();+ expect(screen.getByText("Alert")).toBeTruthy();});- // The bug this guards: 7.4 read amber in the workspace list and green the- // moment you opened the same repo.- it("reads a mid-seven score green, as the repo overview does", () => {+ // The bug this guards: a 7.4 repo read green "Good" here and amber+ // "Warning" on the system map.+ it("reads a mid-seven score as Warning, as the system map does", () => {render(<RepoRows repos={[row({ health: 7.4 })]} />);- expect(screen.getByText("Good")).toBeTruthy();- expect(screen.queryByText("Fair")).toBeNull();+ expect(screen.getByText("Warning")).toBeTruthy();+ expect(screen.queryByText("Good")).toBeNull();});it("does not quote figures for a repo that was never indexed", () => {diff --git a/packages/ui/__tests__/workspace/repo-card.test.tsx b/packages/ui/__tests__/workspace/repo-card.test.tsxindex cdbccdc5d..69ee0117a 100644--- a/packages/ui/__tests__/workspace/repo-card.test.tsx+++ b/packages/ui/__tests__/workspace/repo-card.test.tsx@@ -1,10 +1,7 @@import { describe, expect, it } from "vitest";import { render, screen } from "@testing-library/react";-import { ReactFlowProvider } from "@xyflow/react";-import type { NodeProps } from "@xyflow/react";import { RepoCard } from "../../src/workspace/repo-card.js";-import { WorkspaceGraphNode } from "../../src/workspace/workspace-graph-node.js";describe("RepoCard", () => {it("names the figure as doc confidence, floored", () => {@@ -23,34 +20,3 @@ describe("RepoCard", () => {expect(screen.queryByText(/% docs$/)).toBeNull();});});--function renderNode(healthScore: number | null) {- const data = {- repoId: "r1",- name: "api",- fileCount: 12,- coveragePct: 99.8,- healthScore,- topLanguage: "python",- };- return render(- <ReactFlowProvider>- <WorkspaceGraphNode {...({ data } as unknown as NodeProps)} />- </ReactFlowProvider>,- );-}--describe("WorkspaceGraphNode", () => {- it("labels mean page confidence as doc confidence, not coverage", () => {- renderNode(72);- expect(screen.getByText("99% doc conf.")).toBeInTheDocument();- expect(screen.queryByText(/% cov$/)).toBeNull();- expect(screen.getByLabelText("Health score: 72")).toBeInTheDocument();- });-- it("shows no score for a repo health has not scored", () => {- renderNode(null);- expect(screen.getByText("no score")).toBeInTheDocument();- expect(screen.queryByLabelText(/Health score/)).toBeNull();- });-});diff --git a/packages/ui/__tests__/workspace/system-map-ai-prompt.test.ts b/packages/ui/__tests__/workspace/system-map-ai-prompt.test.tsindex 9a8463531..5ab7ddeff 100644--- a/packages/ui/__tests__/workspace/system-map-ai-prompt.test.ts+++ b/packages/ui/__tests__/workspace/system-map-ai-prompt.test.ts@@ -10,7 +10,6 @@ import {import {edgeLinks,edgeSentence,- healthMark,serviceDiagnostics,serviceResolver,summarizeServiceContracts,@@ -93,12 +92,6 @@ const graph: SystemGraph = {};describe("system map model", () => {- it("reads health in the canonical three bands", () => {- expect(healthMark(85)).toMatchObject({ value: "8.5", label: "Healthy" });- expect(healthMark(67.4)).toMatchObject({ value: "6.7", label: "Warning" });- expect(healthMark(30)).toMatchObject({ label: "Alert" });- });-it("puts a file in its deepest service, else the repo root, and in its repo when collapsed", () => {const resolve = serviceResolver(graph, false);expect(resolve("mono", "packages/web/src/x.ts")).toBe("mono::packages/web");diff --git a/packages/ui/src/health/tokens.ts b/packages/ui/src/health/tokens.tsindex 2aed910ab..d024c132a 100644--- a/packages/ui/src/health/tokens.ts+++ b/packages/ui/src/health/tokens.ts@@ -9,7 +9,10 @@import {bandForScore,+ formatScore,HEALTH_BAND_LABEL,+ HEALTHY_MIN,+ NEEDS_WORK_MIN,type HealthBand,} from "@repowise-dev/types/health";@@ -247,6 +250,40 @@ export function healthBand(score: number): { color: string; label: string } {return { color: HEALTH_BAND_VAR[band], label: HEALTH_BAND_LABEL[band] };}+/**+ * The canonical three bands a label takes beside a health mark: Healthy at+ * `HEALTHY_MIN` or above, Warning from `NEEDS_WORK_MIN`, Alert below. The five+ * bands above are for a standalone lede; a dot, a figure and a word drawn+ * together read on these three, so every mark agrees with every other.+ */+export type HealthMarkBand = "healthy" | "warning" | "alert";++/** Top to bottom, with the lower edge of each band, for keys and grounds. */+export const HEALTH_MARK_BANDS: readonly {+ band: HealthMarkBand;+ label: string;+ color: string;+ min: number;+}[] = [+ { band: "healthy", label: "Healthy", color: "var(--color-success)", min: HEALTHY_MIN },+ { band: "warning", label: "Warning", color: "var(--color-warning)", min: NEEDS_WORK_MIN },+ { band: "alert", label: "Alert", color: "var(--color-error)", min: 0 },+];++export interface HealthMark {+ /** The score at one decimal, floored so it never crosses a band edge. */+ value: string;+ band: HealthMarkBand;+ label: string;+ color: string;+}++/** A 1-10 score as a health mark: figure, word and colour on the three bands. */+export function healthMark(score: number): HealthMark {+ const b = HEALTH_MARK_BANDS.find((x) => score >= x.min) ?? HEALTH_MARK_BANDS[HEALTH_MARK_BANDS.length - 1]!;+ return { value: formatScore(score), band: b.band, label: b.label, color: b.color };+}+export function riskInk(risk01: number): string {if (risk01 >= 0.66) return "var(--color-error)";if (risk01 >= 0.33) return "var(--color-warning)";diff --git a/packages/ui/src/health/trend-chart.tsx b/packages/ui/src/health/trend-chart.tsxindex 7c35962cc..fe60c19e4 100644--- a/packages/ui/src/health/trend-chart.tsx+++ b/packages/ui/src/health/trend-chart.tsx@@ -2,12 +2,12 @@import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";import type { KeyboardEvent, PointerEvent, RefObject } from "react";-import { HEALTHY_MIN, NEEDS_WORK_MIN, formatScore } from "@repowise-dev/types/health";+import { formatScore } from "@repowise-dev/types/health";import { EmptyState } from "../shared/empty-state";import { seriesColor } from "../shared/series";import { formatDate } from "../lib/format";-import { deltaColor, formatDelta } from "./tokens";+import { HEALTH_MARK_BANDS, deltaColor, formatDelta } from "./tokens";export interface TrendSeriesPoint {taken_at: string | null;@@ -62,11 +62,12 @@ const LINES: Record<LineKey, Series> = {};/** The canonical three bands, top to bottom, as faint grounds behind the lines. */-const BANDS = [- { label: "Healthy", from: 10, to: HEALTHY_MIN, fill: "var(--color-success)" },- { label: "Warning", from: HEALTHY_MIN, to: NEEDS_WORK_MIN, fill: "var(--color-warning)" },- { label: "Alert", from: NEEDS_WORK_MIN, to: 0, fill: "var(--color-error)" },-] as const;+const BANDS = HEALTH_MARK_BANDS.map((b, i) => ({+ label: b.label,+ from: i === 0 ? 10 : HEALTH_MARK_BANDS[i - 1]!.min,+ to: b.min,+ fill: b.color,+}));// The right pad holds the band names, outside the lines they would collide with.const PAD = { l: 28, r: 56, t: 10, b: 24 };diff --git a/packages/ui/src/overview/repo-rows.tsx b/packages/ui/src/overview/repo-rows.tsxindex 11325e2db..77edae11c 100644--- a/packages/ui/src/overview/repo-rows.tsx+++ b/packages/ui/src/overview/repo-rows.tsx@@ -1,8 +1,7 @@import * as React from "react";import type { RepoIndexStatus } from "@repowise-dev/types/repos";-import { formatScore } from "@repowise-dev/types/health";import { formatNumber, formatRelativeTime } from "../lib/format";-import { healthBand } from "../health/tokens";+import { healthMark } from "../health/tokens";import { RepoAvatar } from "./repo-avatar";export interface RepoRow {@@ -101,8 +100,8 @@ function figuresFor(repo: RepoRow): string[] {* the ribbon above it.** Health leads the right-hand column because it is the figure that decides- * which repo you open. It is painted on the shared `healthBand`, so the number- * that sends you into a repo means there what it meant here.+ * which repo you open. It is a health mark on the shared three bands, so a+ * repo reads the same word and colour here as on the system map.*/export function RepoRows({ repos, LinkComponent, actionsFor }: RepoRowsProps) {const A = LinkComponent ?? "a";@@ -113,7 +112,7 @@ export function RepoRows({ repos, LinkComponent, actionsFor }: RepoRowsProps) {{repos.map((repo) => {const figures = figuresFor(repo);const actions = actionsFor?.(repo);- const band = repo.health === null ? null : healthBand(repo.health);+ const mark = repo.health === null ? null : healthMark(repo.health);return (<li key={repo.id} className="group">@@ -164,7 +163,7 @@ export function RepoRows({ repos, LinkComponent, actionsFor }: RepoRowsProps) {<p className="font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">Health</p>- {repo.health === null || band === null ? (+ {repo.health === null || mark === null ? (<pclassName="mt-1 text-[15px] leading-none text-[var(--color-text-tertiary)]"title="No health snapshot yet — this repository has not been analysed."@@ -175,15 +174,15 @@ export function RepoRows({ repos, LinkComponent, actionsFor }: RepoRowsProps) {<><pclassName="mt-1 text-[22px] font-semibold leading-none tabular-nums"- style={{ color: band.color }}+ style={{ color: mark.color }}>- {formatScore(repo.health)}+ {mark.value}</p><pclassName="mt-1 text-[11px]"- style={{ color: band.color }}+ style={{ color: mark.color }}>- {band.label}+ {mark.label}</p></>)}diff --git a/packages/ui/src/workspace/index.ts b/packages/ui/src/workspace/index.tsindex 004cf7abe..afb819561 100644--- a/packages/ui/src/workspace/index.ts+++ b/packages/ui/src/workspace/index.ts@@ -19,5 +19,3 @@ export * from "./package-deps-table";export * from "./repo-card";export * from "./repo-card-compact";export * from "./repo-pair-table";-export * from "./workspace-graph";-export * from "./workspace-graph-node";diff --git a/packages/ui/src/workspace/system-map/index.ts b/packages/ui/src/workspace/system-map/index.tsindex f460f7fee..c4759c9a0 100644--- a/packages/ui/src/workspace/system-map/index.ts+++ b/packages/ui/src/workspace/system-map/index.ts@@ -38,7 +38,6 @@ export {SYSTEM_MAP_PROMPT_MAX_ROWS,} from "./system-map-ai-prompt";export {- healthMark,serviceResolver,summarizeServiceContracts,serviceDiagnostics,diff --git a/packages/ui/src/workspace/system-map/system-map-drawer.tsx b/packages/ui/src/workspace/system-map/system-map-drawer.tsxindex a852df935..c0ad4ecdf 100644--- a/packages/ui/src/workspace/system-map/system-map-drawer.tsx+++ b/packages/ui/src/workspace/system-map/system-map-drawer.tsx@@ -27,6 +27,7 @@ import { FilePath } from "../../shared/file-path";import { AiPromptButton } from "../../health/ai-prompt-button";import { AiPromptModal } from "../../health/ai-prompt-modal";import type { AiPromptFlavor } from "../../health/ai-prompt-builder";+import { healthMark } from "../../health/tokens";import { linkStrategyCopy } from "../link-provenance";import { roleStyle } from "./architecture";import { edgeKindStyle, matchTypeLabel } from "./edge-kinds";@@ -40,7 +41,6 @@ import {cyclesWithEdge,edgeLinks,edgeSentence,- healthMark,neighbourGroups,nodeLocation,plural,@@ -264,7 +264,8 @@ function NodeBody({onPrompt,}: BodyProps<{ node: SystemNode }>) {const health = healthByRepo?.get(node.repo);- const mark = health ? healthMark(health.score) : null;+ // Repo health arrives 0-100; the mark reads 0-10.+ const mark = health ? healthMark(health.score / 10) : null;// Roles are computed per service, so a merged repo node has none.const role = collapsed ? undefined : roleByNodeId?.get(node.id);const style = role ? roleStyle(role.role) : null;diff --git a/packages/ui/src/workspace/system-map/system-map-legend.tsx b/packages/ui/src/workspace/system-map/system-map-legend.tsxindex 6c60871bb..f8985b26a 100644--- a/packages/ui/src/workspace/system-map/system-map-legend.tsx+++ b/packages/ui/src/workspace/system-map/system-map-legend.tsx@@ -9,6 +9,7 @@*/import type { SystemEdgeMatchType } from "@repowise-dev/types";+import { HEALTH_MARK_BANDS } from "../../health/tokens";import { matchTypeDash } from "./edge-kinds";function Item({ swatch, label }: { swatch: React.ReactNode; label: string }) {@@ -39,6 +40,15 @@ const LINE_LABEL: Record<SystemEdgeMatchType, string> = {inferred: "Co-change from git history",};+/** "8+", "4 to 8", "below 4": each band's range, read off the shared edges. */+function markRange(i: number): string {+ const b = HEALTH_MARK_BANDS[i]!;+ if (i === 0) return `${b.min}+`;+ const above = HEALTH_MARK_BANDS[i - 1]!.min;+ if (i === HEALTH_MARK_BANDS.length - 1) return `below ${above}`;+ return `${b.min} to ${above}`;+}+export interface SystemMapLegendProps {/** Match types present on the drawn edges; only these get a key. */matchTypes?: ReadonlySet<SystemEdgeMatchType>;@@ -66,9 +76,9 @@ export function SystemMapLegend({ matchTypes }: SystemMapLegendProps) {))}<span className="inline-flex items-center gap-2.5"><span className="text-xs text-[var(--color-text-tertiary)]">Repository health</span>- <Item swatch={<Dot color="var(--color-success)" />} label="Healthy 8+" />- <Item swatch={<Dot color="var(--color-warning)" />} label="Warning 4 to 8" />- <Item swatch={<Dot color="var(--color-error)" />} label="Alert below 4" />+ {HEALTH_MARK_BANDS.map((b, i) => (+ <Item key={b.band} swatch={<Dot color={b.color} />} label={`${b.label} ${markRange(i)}`} />+ ))}</span><span className="text-xs text-[var(--color-text-tertiary)]">Hover a line for its kind and weight. Click a service or line for details.diff --git a/packages/ui/src/workspace/system-map/system-map-model.ts b/packages/ui/src/workspace/system-map/system-map-model.tsindex f67486db6..ca16377df 100644--- a/packages/ui/src/workspace/system-map/system-map-model.ts+++ b/packages/ui/src/workspace/system-map/system-map-model.ts@@ -34,26 +34,6 @@ export interface SystemMapRepoContracts {total: number;}-// ----------------------------------------------------------------------------// Health: the canonical three bands beside a health mark.-// -----------------------------------------------------------------------------export interface HealthMark {- /** 0-10, one decimal. */- value: string;- label: "Healthy" | "Warning" | "Alert";- color: string;-}--/** Repo health arrives 0-100; the product reads it 0-10 in three bands. */-export function healthMark(score100: number): HealthMark {- const score = score100 / 10;- const value = score.toFixed(1);- if (score >= 8) return { value, label: "Healthy", color: "var(--color-success)" };- if (score >= 4) return { value, label: "Warning", color: "var(--color-warning)" };- return { value, label: "Alert", color: "var(--color-error)" };-}-// ---------------------------------------------------------------------------// Files to services.// ---------------------------------------------------------------------------diff --git a/packages/ui/src/workspace/system-map/system-map-node.tsx b/packages/ui/src/workspace/system-map/system-map-node.tsxindex 6d0a09d57..452f342f9 100644--- a/packages/ui/src/workspace/system-map/system-map-node.tsx+++ b/packages/ui/src/workspace/system-map/system-map-node.tsx@@ -12,7 +12,7 @@import { memo } from "react";import { Handle, Position, type NodeProps } from "@xyflow/react";-import { healthMark } from "./system-map-model";+import { healthMark } from "../../health/tokens";import { SYSTEM_MAP_NODE_SIZE } from "./layout";import type { SystemMapNodeData } from "./types";@@ -24,7 +24,8 @@ function badgeColor(tone: "danger" | "warning" | "info"): string {function SystemMapNodeInner({ data, selected }: NodeProps) {const { node, health, overlay, role } = data as unknown as SystemMapNodeData;- const mark = health ? healthMark(health.score) : null;+ // Repo health arrives 0-100; the mark reads 0-10.+ const mark = health ? healthMark(health.score / 10) : null;const lensed = overlay?.highlighted ?? false;const dimmed = overlay?.dimmed ?? false;const where = node.service_path ? `${node.repo} / ${node.service_path}` : `${node.repo} repository`;diff --git a/packages/ui/src/workspace/workspace-graph-node.tsx b/packages/ui/src/workspace/workspace-graph-node.tsxdeleted file mode 100644index fb8c85529..000000000--- a/packages/ui/src/workspace/workspace-graph-node.tsx+++ /dev/null@@ -1,150 +0,0 @@-"use client";--import { memo } from "react";-import { Handle, Position, type NodeProps } from "@xyflow/react";-import { FileText, BarChart3 } from "lucide-react";-import { languageColor } from "../lib/confidence";-import { healthInk100 } from "../health/tokens";--export interface WorkspaceGraphNodeData {- repoId: string;- name: string;- fileCount: number;- /** Mean wiki page confidence, 0-100. */- coveragePct: number;- /** Code health, 0-100; null when health has not scored the repo. */- healthScore: number | null;- topLanguage: string;-}--export function healthColor(score: number): string {- return healthInk100(score);-}--export function HealthRing({ score, size = 36 }: { score: number; size?: number }) {- const r = (size - 4) / 2;- const circ = 2 * Math.PI * r;- const offset = circ * (1 - score / 100);- const color = healthColor(score);- const label = "Health score";-- return (- <svg- width={size}- height={size}- className="shrink-0"- aria-label={`${label}: ${Math.round(score)}`}- >- <title>{label}</title>- <circle- cx={size / 2}- cy={size / 2}- r={r}- fill="none"- stroke="color-mix(in srgb, var(--color-border-default) 10%, transparent)"- strokeWidth={3}- />- <circle- cx={size / 2}- cy={size / 2}- r={r}- fill="none"- stroke={color}- strokeWidth={3}- strokeDasharray={circ}- strokeDashoffset={offset}- strokeLinecap="round"- transform={`rotate(-90 ${size / 2} ${size / 2})`}- />- <text- x={size / 2}- y={size / 2}- textAnchor="middle"- dominantBaseline="central"- fill={color}- fontSize={10}- fontWeight={700}- >- {Math.round(score)}- </text>- </svg>- );-}--function HealthCell({ score }: { score: number | null }) {- return (- <div className="flex flex-col items-center gap-0.5">- {score != null ? (- <HealthRing score={score} />- ) : (- <span className="text-[10px] text-[var(--color-text-tertiary)]">—</span>- )}- <span className="text-[8px] font-medium uppercase tracking-wide text-[var(--color-text-tertiary)]">- {score != null ? "health" : "no score"}- </span>- </div>- );-}--function WorkspaceGraphNodeInner({ data }: NodeProps) {- const d = data as unknown as WorkspaceGraphNodeData;- const langColor = languageColor(d.topLanguage);-- return (- <div- className="rounded-xl cursor-pointer transition-shadow duration-200 hover:shadow-xl"- style={{- width: 160,- minHeight: 100,- background: `linear-gradient(135deg, ${langColor}25 0%, color-mix(in srgb, var(--color-bg-surface) 95%, transparent) 60%)`,- border: `2px solid ${langColor}60`,- boxShadow: `0 2px 12px rgba(0,0,0,0.3), 0 0 0 1px ${langColor}20`,- padding: "10px 12px",- }}- >- <Handle- type="target"- position={Position.Top}- className="!w-2 !h-2 !bg-[var(--color-border-subtle)] !border-none"- />-- <div className="text-[12px] font-bold text-[var(--color-text-primary)] truncate text-center mb-2">- {d.name}- </div>-- <div className="flex items-center gap-2.5">- <HealthCell score={d.healthScore} />- <div className="flex-1 min-w-0 space-y-1">- <div className="flex items-center gap-1 text-[10px] text-[var(--color-text-secondary)]">- <FileText className="w-3 h-3 shrink-0" />- <span>{d.fileCount} files</span>- </div>- <div className="flex items-center gap-1 text-[10px] text-[var(--color-text-secondary)]">- <BarChart3 className="w-3 h-3 shrink-0" />- <span title="Average confidence of the generated doc pages">- {Math.floor(d.coveragePct)}% doc conf.- </span>- </div>- </div>- </div>-- <div- className="mt-2 text-[10px] font-medium px-1.5 py-0.5 rounded-full text-center"- style={{- background: `${langColor}30`,- color: langColor,- }}- >- {d.topLanguage}- </div>-- <Handle- type="source"- position={Position.Bottom}- className="!w-2 !h-2 !bg-[var(--color-border-subtle)] !border-none"- />- </div>- );-}--export const WorkspaceGraphNode = memo(WorkspaceGraphNodeInner);diff --git a/packages/ui/src/workspace/workspace-graph.tsx b/packages/ui/src/workspace/workspace-graph.tsxdeleted file mode 100644index 3fca974d7..000000000--- a/packages/ui/src/workspace/workspace-graph.tsx+++ /dev/null@@ -1,156 +0,0 @@-"use client";--import { useMemo, useCallback } from "react";-import {- ReactFlow,- Controls,- Background,- BackgroundVariant,- ReactFlowProvider,- type Node,- type Edge,-} from "@xyflow/react";-import "@xyflow/react/dist/style.css";-import {- forceSimulation,- forceManyBody,- forceLink,- forceCollide,- forceCenter,-} from "d3-force";-import { WorkspaceGraphNode, type WorkspaceGraphNodeData } from "./workspace-graph-node";--export interface WorkspaceGraphData {- nodes: Array<{- repo_id: string;- name: string;- file_count: number;- coverage_pct: number;- health_score: number | null;- top_language: string;- }>;- edges: Array<{- source: string;- target: string;- type: "contract" | "co_change";- strength: number;- label: string | null;- }>;-}--export interface WorkspaceGraphProps {- data: WorkspaceGraphData;- onRepoClick?: (repoId: string) => void;-}--const nodeTypes = { workspaceRepo: WorkspaceGraphNode };--interface SimNode {- id: string;- x?: number;- y?: number;- vx?: number;- vy?: number;-}--function computeLayout(data: WorkspaceGraphData): { nodes: Node[]; edges: Edge[] } {- if (data.nodes.length === 0) return { nodes: [], edges: [] };-- const nodeSet = new Set(data.nodes.map((n) => n.repo_id));- const simNodes: SimNode[] = data.nodes.map((n) => ({ id: n.repo_id }));- const simLinks = data.edges- .filter((e) => nodeSet.has(e.source) && nodeSet.has(e.target))- .map((e) => ({ source: e.source, target: e.target }));-- /* eslint-disable @typescript-eslint/no-explicit-any */- const sim = forceSimulation(simNodes as any[])- .force("charge", forceManyBody().strength(-400))- .force(- "link",- forceLink(simLinks as any[])- .id((d: any) => d.id)- .distance(200),- )- .force("collide", forceCollide(100))- .force("center", forceCenter(0, 0))- .stop();- /* eslint-enable @typescript-eslint/no-explicit-any */-- for (let i = 0; i < 100; i++) sim.tick();-- const rfNodes: Node[] = simNodes.map((sn) => {- const apiNode = data.nodes.find((n) => n.repo_id === sn.id)!;- return {- id: sn.id,- type: "workspaceRepo",- position: { x: sn.x ?? 0, y: sn.y ?? 0 },- data: {- repoId: apiNode.repo_id,- name: apiNode.name,- fileCount: apiNode.file_count,- coveragePct: apiNode.coverage_pct,- healthScore: apiNode.health_score,- topLanguage: apiNode.top_language,- } satisfies WorkspaceGraphNodeData,- };- });-- const rfEdges: Edge[] = data.edges- .filter((e) => nodeSet.has(e.source) && nodeSet.has(e.target))- .map((e, i) => ({- id: `ws-edge-${i}`,- source: e.source,- target: e.target,- label: e.label ?? undefined,- style: {- strokeWidth: Math.min(1 + e.strength * 4, 10),- stroke: e.type === "contract" ? "var(--color-accent-secondary)" : "var(--color-edge-co-change)",- strokeDasharray: e.type === "co_change" ? "6 3" : undefined,- },- labelStyle: { fontSize: 10, fill: "var(--color-text-tertiary)" },- }));-- return { nodes: rfNodes, edges: rfEdges };-}--function WorkspaceGraphInner({ data, onRepoClick }: WorkspaceGraphProps) {- const { nodes, edges } = useMemo(() => computeLayout(data), [data]);-- const handleNodeClick = useCallback(- (_: React.MouseEvent, node: Node) => {- const d = node.data as unknown as WorkspaceGraphNodeData;- onRepoClick?.(d.repoId);- },- [onRepoClick],- );-- return (- <ReactFlow- nodes={nodes}- edges={edges}- nodeTypes={nodeTypes}- onNodeClick={handleNodeClick}- fitView- fitViewOptions={{ padding: 0.3, maxZoom: 1.2 }}- minZoom={0.3}- maxZoom={2}- proOptions={{ hideAttribution: true }}- nodesDraggable- className="!bg-transparent"- >- <Background variant={BackgroundVariant.Dots} gap={20} size={0.5} color="rgba(255,255,255,0.03)" />- <Controls- showInteractive={false}- className="!border-[var(--color-border-default)] !bg-[var(--color-bg-elevated)] !shadow-lg [&>button]:!border-[var(--color-border-default)] [&>button]:!bg-[var(--color-bg-elevated)] [&>button]:!text-[var(--color-text-secondary)] [&>button:hover]:!bg-[var(--color-bg-overlay)] [&>button:hover]:!text-[var(--color-text-primary)]"- />- </ReactFlow>- );-}--export function WorkspaceGraph(props: WorkspaceGraphProps) {- return (- <ReactFlowProvider>- <WorkspaceGraphInner {...props} />- </ReactFlowProvider>- );-}diff --git a/packages/web/src/app/workspace/page.tsx b/packages/web/src/app/workspace/page.tsxindex 6b8c02403..824be183b 100644--- a/packages/web/src/app/workspace/page.tsx+++ b/packages/web/src/app/workspace/page.tsx@@ -290,7 +290,7 @@ function toRow(repo: WorkspaceRepoEntry): RepoRow {localPath: repo.path,href: repo.repo_id ? `/repos/${repo.repo_id}/overview` : "/workspace",status: statusOf(repo),- // The wire carries 0-100; RepoRows and `bandForScore` are both 0-10.+ // The wire carries 0-100; RepoRows reads 0-10.// Optional on the type, so a web build ahead of its server shows "—"// rather than NaN.health: repo.health_score == null ? null : repo.health_score / 10,