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
"use client";
import { useState } from "react";
import { FilePath } from "../shared/file-path";
interface CoChangeListProps {
partners: Array<{ file_path: string; co_change_count: number }>;
/**
* Number of rows rendered when collapsed. The control toggles to the
* full list — partners are already trimmed server-side by ``min_count``
* so the full set is bounded.
*/
previewCount?: number;
}
export function CoChangeList({ partners, previewCount = 5 }: CoChangeListProps) {
const [expanded, setExpanded] = useState(false);
if (partners.length === 0) return null;
// `reduce`, not a spread: the partner list is uncapped, and a long one
// overflows the call stack as an argument list.
const maxCount = partners.reduce((m, p) => Math.max(m, p.co_change_count), 0);
const visible = expanded ? partners : partners.slice(0, previewCount);
const hidden = partners.length - visible.length;
return (
<div className="space-y-1.5">
{visible.map((p) => (
<div key={p.file_path} className="space-y-0.5">
<div className="flex items-center justify-between text-xs">
<FilePath path={p.file_path} fold className="flex-1 text-[var(--color-text-secondary)]" />
<span className="text-[var(--color-text-tertiary)] tabular-nums shrink-0 ml-1">
{p.co_change_count}×
</span>
</div>
<div className="h-1 w-full rounded-full bg-[var(--color-bg-elevated)]">
<div
className="h-1 rounded-full bg-[var(--color-progress-fill)] transition-all"
style={{
width: `${maxCount > 0 ? (p.co_change_count / maxCount) * 100 : 0}%`,
}}
/>
</div>
</div>
))}
{(hidden > 0 || expanded) && (
<button
type="button"
onClick={() => setExpanded((v) => !v)}
className="text-[10px] text-[var(--color-accent-primary)] hover:underline"
>
{expanded ? "Show fewer" : `Show ${hidden} more`}
</button>
)}
</div>
);
}