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.

Add rich git visualizations to web UI and fix QoL issues across all pages

RaghavChamadiyad3f7e65c71c7
diff --git a/packages/server/src/repowise/server/routers/git.py b/packages/server/src/repowise/server/routers/git.py
index a7f8e9982..3221f62b3 100644
--- a/packages/server/src/repowise/server/routers/git.py
+++ b/packages/server/src/repowise/server/routers/git.py
@@ -59,9 +59,17 @@ async def get_hotspots(
HotspotResponse(
file_path=r.file_path,
commit_count_90d=r.commit_count_90d,
+ commit_count_30d=r.commit_count_30d,
churn_percentile=r.churn_percentile,
primary_owner=r.primary_owner_name,
is_hotspot=r.is_hotspot,
+ is_stable=r.is_stable,
+ bus_factor=r.bus_factor or 0,
+ contributor_count=r.contributor_count or 0,
+ lines_added_90d=r.lines_added_90d or 0,
+ lines_deleted_90d=r.lines_deleted_90d or 0,
+ avg_commit_size=r.avg_commit_size or 0.0,
+ commit_categories=json.loads(r.commit_categories_json) if r.commit_categories_json else {},
)
for r in rows
]
@@ -135,7 +143,7 @@ async def get_co_changes(
raise HTTPException(status_code=404, detail="Git metadata not found")
partners = json.loads(meta.co_change_partners_json)
- filtered = [p for p in partners if p.get("count", 0) >= min_count]
+ filtered = [p for p in partners if p.get("co_change_count", 0) >= min_count]
return {
"file_path": file_path,
@@ -161,8 +169,12 @@ async def get_git_summary(
for m in all_meta:
if m.primary_owner_name:
owners[m.primary_owner_name] = owners.get(m.primary_owner_name, 0) + 1
+ total = len(all_meta) or 1
top_owners = sorted(
- [{"name": k, "file_count": v} for k, v in owners.items()],
+ [
+ {"name": k, "file_count": v, "pct": v / total}
+ for k, v in owners.items()
+ ],
key=lambda x: x["file_count"],
reverse=True,
)[:10]
diff --git a/packages/server/src/repowise/server/schemas.py b/packages/server/src/repowise/server/schemas.py
index e3da2b875..6498052af 100644
--- a/packages/server/src/repowise/server/schemas.py
+++ b/packages/server/src/repowise/server/schemas.py
@@ -301,6 +301,8 @@ class GitMetadataResponse(BaseModel):
primary_owner_name: str | None
primary_owner_email: str | None
primary_owner_commit_pct: float | None
+ recent_owner_name: str | None
+ recent_owner_commit_pct: float | None
top_authors: list[dict]
significant_commits: list[dict]
co_change_partners: list[dict]
@@ -308,6 +310,13 @@ class GitMetadataResponse(BaseModel):
is_stable: bool
churn_percentile: float
age_days: int
+ bus_factor: int
+ contributor_count: int
+ lines_added_90d: int
+ lines_deleted_90d: int
+ avg_commit_size: float
+ commit_categories: dict
+ merge_commit_count_90d: int
@classmethod
def from_orm(cls, obj: object) -> GitMetadataResponse:
@@ -321,6 +330,8 @@ class GitMetadataResponse(BaseModel):
primary_owner_name=obj.primary_owner_name, # type: ignore[attr-defined]
primary_owner_email=obj.primary_owner_email, # type: ignore[attr-defined]
primary_owner_commit_pct=obj.primary_owner_commit_pct, # type: ignore[attr-defined]
+ recent_owner_name=obj.recent_owner_name, # type: ignore[attr-defined]
+ recent_owner_commit_pct=obj.recent_owner_commit_pct, # type: ignore[attr-defined]
top_authors=json.loads(obj.top_authors_json), # type: ignore[attr-defined]
significant_commits=json.loads(obj.significant_commits_json), # type: ignore[attr-defined]
co_change_partners=json.loads(obj.co_change_partners_json), # type: ignore[attr-defined]
@@ -328,15 +339,30 @@ class GitMetadataResponse(BaseModel):
is_stable=obj.is_stable, # type: ignore[attr-defined]
churn_percentile=obj.churn_percentile, # type: ignore[attr-defined]
age_days=obj.age_days, # type: ignore[attr-defined]
+ bus_factor=obj.bus_factor or 0, # type: ignore[attr-defined]
+ contributor_count=obj.contributor_count or 0, # type: ignore[attr-defined]
+ lines_added_90d=obj.lines_added_90d or 0, # type: ignore[attr-defined]
+ lines_deleted_90d=obj.lines_deleted_90d or 0, # type: ignore[attr-defined]
+ avg_commit_size=obj.avg_commit_size or 0.0, # type: ignore[attr-defined]
+ commit_categories=json.loads(obj.commit_categories_json) if obj.commit_categories_json else {}, # type: ignore[attr-defined]
+ merge_commit_count_90d=obj.merge_commit_count_90d or 0, # type: ignore[attr-defined]
)
class HotspotResponse(BaseModel):
file_path: str
commit_count_90d: int
+ commit_count_30d: int
churn_percentile: float
primary_owner: str | None
is_hotspot: bool
+ is_stable: bool
+ bus_factor: int
+ contributor_count: int
+ lines_added_90d: int
+ lines_deleted_90d: int
+ avg_commit_size: float
+ commit_categories: dict
class OwnershipEntry(BaseModel):
diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx
index f175eb11f..45ffe4b1e 100644
--- a/packages/web/src/app/page.tsx
+++ b/packages/web/src/app/page.tsx
@@ -11,6 +11,8 @@ import {
} from "lucide-react";
import { listRepos, getRepoStats } from "@/lib/api/repos";
import { listJobs } from "@/lib/api/jobs";
+import { getGitSummary } from "@/lib/api/git";
+import type { RepoStatsResponse, GitSummaryResponse } from "@/lib/api/types";
import { StatCard } from "@/components/shared/stat-card";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
@@ -32,23 +34,38 @@ export default async function DashboardPage() {
const repoList = repos.status === "fulfilled" ? repos.value : [];
const jobList = jobs.status === "fulfilled" ? jobs.value : [];
- // Aggregate stats across all repos
+ // Fetch per-repo stats and git summaries
const statsResults = await Promise.allSettled(
repoList.map((r) => getRepoStats(r.id)),
);
- const allStats = statsResults
- .filter((r): r is PromiseFulfilledResult<Awaited<ReturnType<typeof getRepoStats>>> => r.status === "fulfilled")
- .map((r) => r.value);
+ const gitResults = await Promise.allSettled(
+ repoList.map((r) => getGitSummary(r.id)),
+ );
+
+ const statsMap = new Map<string, RepoStatsResponse>();
+ const gitMap = new Map<string, GitSummaryResponse>();
+ repoList.forEach((r, i) => {
+ if (statsResults[i]?.status === "fulfilled")
+ statsMap.set(r.id, (statsResults[i] as PromiseFulfilledResult<RepoStatsResponse>).value);
+ if (gitResults[i]?.status === "fulfilled")
+ gitMap.set(r.id, (gitResults[i] as PromiseFulfilledResult<GitSummaryResponse>).value);
+ });
- const totalFiles = allStats.reduce((s, st) => s + st.file_count, 0);
- const totalSymbols = allStats.reduce((s, st) => s + st.symbol_count, 0);
- const avgCoverage = allStats.length > 0
- ? Math.round(allStats.reduce((s, st) => s + st.doc_coverage_pct, 0) / allStats.length)
- : 0;
- const avgFreshness = allStats.length > 0
- ? Math.round(allStats.reduce((s, st) => s + st.freshness_score, 0) / allStats.length)
- : 0;
- const totalDeadCode = allStats.reduce((s, st) => s + st.dead_export_count, 0);
+ // Aggregate stats across all repos
+ let totalFiles = 0;
+ let totalSymbols = 0;
+ let totalDeadCode = 0;
+ let totalCoverage = 0;
+ let totalFreshness = 0;
+ for (const s of statsMap.values()) {
+ totalFiles += s.file_count;
+ totalSymbols += s.symbol_count;
+ totalDeadCode += s.dead_export_count;
+ totalCoverage += s.doc_coverage_pct;
+ totalFreshness += s.freshness_score;
+ }
+ const avgCoverage = statsMap.size > 0 ? Math.round(totalCoverage / statsMap.size) : 0;
+ const avgFreshness = statsMap.size > 0 ? Math.round(totalFreshness / statsMap.size) : 0;
return (
<div className="p-4 sm:p-6 space-y-6 max-w-[1200px]">
@@ -80,8 +97,8 @@ export default async function DashboardPage() {
/>
<StatCard
label="Dead Code"
- value={formatNumber(totalDeadCode)}
- description="Unused exports"
+ value={totalDeadCode > 0 ? formatNumber(totalDeadCode) : "—"}
+ description={totalDeadCode > 0 ? "Unused exports" : "Analyze to detect"}
icon={<Skull className="h-4 w-4 text-[var(--color-text-tertiary)]" />}
/>
</div>
@@ -117,11 +134,11 @@ export default async function DashboardPage() {
</p>
</div>
<div className="flex items-center gap-2 mt-0.5">
- <p className="text-xs text-[var(--color-text-tertiary)] font-mono truncate">
+ <p className="text-xs text-[var(--color-text-tertiary)] font-mono truncate" title={repo.local_path}>
{repo.local_path}
</p>
</div>
- <div className="flex items-center gap-2 mt-1">
+ <div className="flex items-center gap-2 mt-1 flex-wrap">
{repo.head_commit && (
<span className="text-xs font-mono text-[var(--color-text-tertiary)]">
{repo.head_commit.slice(0, 7)}
@@ -130,6 +147,19 @@ export default async function DashboardPage() {
<span className="text-xs text-[var(--color-text-tertiary)]">
Updated {formatRelativeTime(repo.updated_at)}
</span>
+ {gitMap.has(repo.id) && (() => {
+ const g = gitMap.get(repo.id)!;
+ return (
+ <>
+ {g.hotspot_count > 0 && (
+ <Badge variant="outdated">{g.hotspot_count} hotspot{g.hotspot_count !== 1 ? "s" : ""}</Badge>
+ )}
+ {g.stable_count > 0 && (
+ <Badge variant="fresh">{g.stable_count} stable</Badge>
+ )}
+ </>
+ );
+ })()}
</div>
</div>
</Link>
diff --git a/packages/web/src/app/repos/[id]/coverage/loading.tsx b/packages/web/src/app/repos/[id]/coverage/loading.tsx
index a798ce3ba..0c30880e3 100644
--- a/packages/web/src/app/repos/[id]/coverage/loading.tsx
+++ b/packages/web/src/app/repos/[id]/coverage/loading.tsx
@@ -2,7 +2,7 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function CoverageLoading() {
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<Skeleton className="h-7 w-36" />
<Skeleton className="h-4 w-52 mt-1.5" />
diff --git a/packages/web/src/app/repos/[id]/coverage/page.tsx b/packages/web/src/app/repos/[id]/coverage/page.tsx
index 8e6bafaab..d47c1c432 100644
--- a/packages/web/src/app/repos/[id]/coverage/page.tsx
+++ b/packages/web/src/app/repos/[id]/coverage/page.tsx
@@ -31,7 +31,7 @@ export default async function CoveragePage({
const freshPct = pages.length > 0 ? Math.round((fresh / pages.length) * 100) : 0;
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">
<FileCheck className="h-5 w-5 text-[var(--color-accent-primary)]" />
diff --git a/packages/web/src/app/repos/[id]/dead-code/loading.tsx b/packages/web/src/app/repos/[id]/dead-code/loading.tsx
index 7f91d7252..e399932d6 100644
--- a/packages/web/src/app/repos/[id]/dead-code/loading.tsx
+++ b/packages/web/src/app/repos/[id]/dead-code/loading.tsx
@@ -2,7 +2,7 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function DeadCodeLoading() {
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<Skeleton className="h-7 w-32" />
diff --git a/packages/web/src/app/repos/[id]/dead-code/page.tsx b/packages/web/src/app/repos/[id]/dead-code/page.tsx
index 6d3349b11..8c39f4337 100644
--- a/packages/web/src/app/repos/[id]/dead-code/page.tsx
+++ b/packages/web/src/app/repos/[id]/dead-code/page.tsx
@@ -37,7 +37,7 @@ export default function DeadCodePage() {
};
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">
diff --git a/packages/web/src/app/repos/[id]/hotspots/loading.tsx b/packages/web/src/app/repos/[id]/hotspots/loading.tsx
index 246694e07..4d15ce5e9 100644
--- a/packages/web/src/app/repos/[id]/hotspots/loading.tsx
+++ b/packages/web/src/app/repos/[id]/hotspots/loading.tsx
@@ -2,18 +2,22 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function HotspotsLoading() {
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<Skeleton className="h-7 w-32" />
<Skeleton className="h-4 w-52 mt-1.5" />
</div>
- <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
- {Array.from({ length: 4 }).map((_, i) => (
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-5">
+ {Array.from({ length: 5 }).map((_, i) => (
<Skeleton key={i} className="h-20 rounded-lg" />
))}
</div>
- <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
- <div className="lg:col-span-2">
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
+ <Skeleton className="lg:col-span-2 h-[240px] rounded-lg" />
+ <Skeleton className="h-[240px] rounded-lg" />
+ </div>
+ <div className="grid grid-cols-1 gap-6 xl:grid-cols-4">
+ <div className="xl:col-span-3">
<Skeleton className="h-[400px] rounded-lg" />
</div>
<Skeleton className="h-[300px] rounded-lg" />
diff --git a/packages/web/src/app/repos/[id]/hotspots/page.tsx b/packages/web/src/app/repos/[id]/hotspots/page.tsx
index dc3fc56c4..60e5297f7 100644
--- a/packages/web/src/app/repos/[id]/hotspots/page.tsx
+++ b/packages/web/src/app/repos/[id]/hotspots/page.tsx
@@ -1,8 +1,10 @@
import type { Metadata } from "next";
-import { Flame } from "lucide-react";
+import { Flame, Shield } from "lucide-react";
import { StatCard } from "@/components/shared/stat-card";
import { HotspotTable } from "@/components/git/hotspot-table";
import { ContributorBar } from "@/components/git/contributor-bar";
+import { ChurnHistogram } from "@/components/git/churn-histogram";
+import { CommitCategoryDonut } from "@/components/git/commit-category-donut";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { getHotspots, getGitSummary } from "@/lib/api/git";
import { formatNumber } from "@/lib/utils/format";
@@ -21,15 +23,25 @@ export default async function HotspotsPage({
try {
[hotspots, summary] = await Promise.all([
- getHotspots(id, 50),
+ getHotspots(id, 100),
getGitSummary(id),
]);
} catch {
// API unavailable
}
+ // Aggregate commit categories across all hotspot files
+ const aggregatedCategories: Record<string, number> = {};
+ for (const h of hotspots) {
+ for (const [cat, count] of Object.entries(h.commit_categories || {})) {
+ aggregatedCategories[cat] = (aggregatedCategories[cat] || 0) + (count as number);
+ }
+ }
+
+ const busFactorRiskCount = hotspots.filter((h) => h.bus_factor <= 1).length;
+
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">
<Flame className="h-5 w-5 text-red-500" />
@@ -42,7 +54,7 @@ export default async function HotspotsPage({
{/* Summary cards */}
{summary && (
- <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-5">
<StatCard
label="Hotspot Files"
value={formatNumber(summary.hotspot_count)}
@@ -63,11 +75,43 @@ export default async function HotspotsPage({
value={`${Math.round(summary.average_churn_percentile)}%`}
description="percentile"
/>
+ <StatCard
+ label="Bus Factor Risk"
+ value={formatNumber(busFactorRiskCount)}
+ description="files with factor ≤ 1"
+ icon={<Shield className="h-4 w-4 text-red-400" />}
+ />
+ </div>
+ )}
+
+ {/* Charts row */}
+ {hotspots.length > 0 && (
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
+ <Card className="lg:col-span-2">
+ <CardHeader className="pb-2">
+ <CardTitle className="text-sm">Churn Distribution</CardTitle>
+ </CardHeader>
+ <CardContent className="pt-0">
+ <ChurnHistogram hotspots={hotspots} />
+ </CardContent>
+ </Card>
+
+ {Object.keys(aggregatedCategories).length > 0 && (
+ <Card>
+ <CardHeader className="pb-2">
+ <CardTitle className="text-sm">Commit Types</CardTitle>
+ </CardHeader>
+ <CardContent className="pt-0 flex items-center justify-center">
+ <CommitCategoryDonut categories={aggregatedCategories} />
+ </CardContent>
+ </Card>
+ )}
</div>
)}
- <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
- <div className="lg:col-span-2">
+ {/* Table + sidebar */}
+ <div className="grid grid-cols-1 gap-6 xl:grid-cols-4">
+ <div className="xl:col-span-3">
<HotspotTable hotspots={hotspots} />
</div>
@@ -80,8 +124,8 @@ export default async function HotspotsPage({
<CardContent className="pt-0">
<ContributorBar owners={summary.top_owners} />
<div className="mt-3 space-y-1.5">
- {summary.top_owners.slice(0, 5).map((o) => (
- <div key={o.email || `owner-${o.name}`} className="flex items-center justify-between text-xs">
+ {summary.top_owners.slice(0, 5).map((o, i) => (
+ <div key={o.email || `owner-${i}`} className="flex items-center justify-between text-xs">
<span className="text-[var(--color-text-secondary)] truncate">{o.name}</span>
<span className="text-[var(--color-text-tertiary)] tabular-nums ml-2">
{formatNumber(o.file_count)} files ({Math.round(o.pct * 100)}%)
diff --git a/packages/web/src/app/repos/[id]/ownership/loading.tsx b/packages/web/src/app/repos/[id]/ownership/loading.tsx
index 6cf2f07cb..0186b1b73 100644
--- a/packages/web/src/app/repos/[id]/ownership/loading.tsx
+++ b/packages/web/src/app/repos/[id]/ownership/loading.tsx
@@ -2,23 +2,22 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function OwnershipLoading() {
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<Skeleton className="h-7 w-36" />
<Skeleton className="h-4 w-52 mt-1.5" />
</div>
- <div className="flex gap-2">
- <Skeleton className="h-9 w-36" />
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
+ {Array.from({ length: 4 }).map((_, i) => (
+ <Skeleton key={i} className="h-20 rounded-lg" />
+ ))}
</div>
- <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
- <div className="lg:col-span-2">
- <Skeleton className="h-[400px] rounded-lg" />
- </div>
- <div className="space-y-4">
- <Skeleton className="h-[200px] rounded-lg" />
- <Skeleton className="h-[160px] rounded-lg" />
- </div>
+ <Skeleton className="h-[320px] rounded-lg" />
+ <div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
+ <Skeleton className="h-[250px] rounded-lg" />
+ <Skeleton className="h-[250px] rounded-lg" />
</div>
+ <Skeleton className="h-[300px] rounded-lg" />
</div>
);
}
diff --git a/packages/web/src/app/repos/[id]/ownership/page.tsx b/packages/web/src/app/repos/[id]/ownership/page.tsx
index fc05585fe..48d494fd5 100644
--- a/packages/web/src/app/repos/[id]/ownership/page.tsx
+++ b/packages/web/src/app/repos/[id]/ownership/page.tsx
@@ -3,15 +3,18 @@
import { useState } from "react";
import useSWR from "swr";
import { useParams } from "next/navigation";
-import { Users } from "lucide-react";
+import { Users, Shield } from "lucide-react";
+import { StatCard } from "@/components/shared/stat-card";
import { OwnershipTable } from "@/components/git/ownership-table";
import { ContributorBar } from "@/components/git/contributor-bar";
+import { OwnershipTreemap } from "@/components/git/ownership-treemap";
+import { BusFactorPanel } from "@/components/git/bus-factor-panel";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
-import { getOwnership, getGitSummary } from "@/lib/api/git";
+import { getOwnership, getGitSummary, getHotspots } from "@/lib/api/git";
import { formatNumber } from "@/lib/utils/format";
import { cn } from "@/lib/utils/cn";
-import type { OwnershipEntry, GitSummaryResponse } from "@/lib/api/types";
+import type { OwnershipEntry, GitSummaryResponse, HotspotResponse } from "@/lib/api/types";
type Granularity = "module" | "file";
@@ -32,10 +35,17 @@ export default function OwnershipPage() {
{ revalidateOnFocus: false },
);
+ const { data: hotspotData } = useSWR<HotspotResponse[]>(
+ `hotspots-for-ownership:${id}`,
+ () => getHotspots(id, 100),
+ { revalidateOnFocus: false },
+ );
+
const siloCount = (entries ?? []).filter((e) => e.is_silo).length;
+ const busFactorRiskCount = (hotspotData ?? []).filter((h) => h.bus_factor <= 1).length;
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">
<Users className="h-5 w-5 text-[var(--color-accent-primary)]" />
@@ -48,67 +58,76 @@ export default function OwnershipPage() {
{/* Summary stats */}
{summary && (
- <div className="grid grid-cols-3 gap-3">
- <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4">
- <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-1">
- Total Files
- </p>
- <p className="text-2xl font-bold text-[var(--color-text-primary)] tabular-nums">
- {formatNumber(summary.total_files)}
- </p>
- </div>
- <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4">
- <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-1">
- Silo Modules
- </p>
- <p className="text-2xl font-bold text-yellow-500 tabular-nums">{siloCount}</p>
- </div>
- <div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4">
- <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-1">
- Contributors
- </p>
- <p className="text-2xl font-bold text-[var(--color-text-primary)] tabular-nums">
- {summary.top_owners.length}
- </p>
- </div>
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
+ <StatCard
+ label="Total Files"
+ value={formatNumber(summary.total_files)}
+ description="with git history"
+ />
+ <StatCard
+ label="Silo Modules"
+ value={siloCount}
+ description="owner >80%"
+ trend={siloCount > 0 ? { value: `${siloCount}`, positive: false } : undefined}
+ />
+ <StatCard
+ label="Contributors"
+ value={summary.top_owners.length}
+ description="unique owners"
+ />
+ <StatCard
+ label="Bus Factor Risk"
+ value={formatNumber(busFactorRiskCount)}
+ description="files with factor ≤ 1"
+ icon={<Shield className="h-4 w-4 text-red-400" />}
+ />
</div>
)}
- {/* Granularity toggle */}
- <div className="flex items-center gap-2">
- <span className="text-xs text-[var(--color-text-secondary)]">View by:</span>
- <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">
- {(["module", "file"] as Granularity[]).map((g) => (
- <button
- key={g}
- onClick={() => setGranularity(g)}
- className={cn(
- "px-3 py-1.5 font-medium transition-colors capitalize",
- granularity === g
- ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"
- : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",
- )}
- >
- {g}
- </button>
- ))}
- </div>
- </div>
-
- <div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
- <div className="lg:col-span-2">
- {loadingEntries ? (
- <div className="space-y-2">
- {Array.from({ length: 8 }).map((_, i) => (
- <Skeleton key={i} className="h-10 w-full" />
- ))}
+ {/* Treemap visualization */}
+ {entries && entries.length > 0 && (
+ <Card>
+ <CardHeader className="pb-2">
+ <div className="flex items-center justify-between">
+ <CardTitle className="text-sm">Ownership Map</CardTitle>
+ {/* Granularity toggle */}
+ <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">
+ {(["module", "file"] as Granularity[]).map((g) => (
+ <button
+ key={g}
+ onClick={() => setGranularity(g)}
+ className={cn(
+ "px-3 py-1.5 font-medium transition-colors capitalize",
+ granularity === g
+ ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"
+ : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",
+ )}
+ >
+ {g}
+ </button>
+ ))}
+ </div>
</div>
- ) : (
- <OwnershipTable entries={entries ?? []} />
- )}
- </div>
+ </CardHeader>
+ <CardContent className="pt-0">
+ <OwnershipTreemap entries={entries} />
+ </CardContent>
+ </Card>
+ )}
+
+ {/* Bus Factor + Contributor sidebar */}
+ <div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
+ {hotspotData && hotspotData.length > 0 && (
+ <Card>
+ <CardHeader className="pb-2">
+ <CardTitle className="text-sm">Bus Factor Analysis</CardTitle>
+ </CardHeader>
+ <CardContent className="pt-0">
+ <BusFactorPanel hotspots={hotspotData} />
+ </CardContent>
+ </Card>
+ )}
- {/* Contributor chart */}
{summary && summary.top_owners.length > 0 && (
<Card>
<CardHeader className="pb-2">
@@ -130,6 +149,17 @@ export default function OwnershipPage() {
</Card>
)}
</div>
+
+ {/* Detail table */}
+ {loadingEntries ? (
+ <div className="space-y-2">
+ {Array.from({ length: 8 }).map((_, i) => (
+ <Skeleton key={i} className="h-10 w-full" />
+ ))}
+ </div>
+ ) : (
+ <OwnershipTable entries={entries ?? []} />
+ )}
</div>
);
}
diff --git a/packages/web/src/app/repos/[id]/symbols/loading.tsx b/packages/web/src/app/repos/[id]/symbols/loading.tsx
index 9984d9e54..2ee853743 100644
--- a/packages/web/src/app/repos/[id]/symbols/loading.tsx
+++ b/packages/web/src/app/repos/[id]/symbols/loading.tsx
@@ -2,7 +2,7 @@ import { Skeleton } from "@/components/ui/skeleton";
export default function SymbolsLoading() {
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<Skeleton className="h-7 w-36" />
<Skeleton className="h-4 w-56 mt-1.5" />
diff --git a/packages/web/src/app/repos/[id]/symbols/page.tsx b/packages/web/src/app/repos/[id]/symbols/page.tsx
index cb335abd1..41420d994 100644
--- a/packages/web/src/app/repos/[id]/symbols/page.tsx
+++ b/packages/web/src/app/repos/[id]/symbols/page.tsx
@@ -12,7 +12,7 @@ export default async function SymbolsPage({
const { id } = await params;
return (
- <div className="p-4 sm:p-6 space-y-6 max-w-6xl">
+ <div className="p-4 sm:p-6 space-y-6 max-w-[1600px]">
<div>
<h1 className="text-xl font-semibold text-[var(--color-text-primary)] mb-1 flex items-center gap-2">
<Code2 className="h-5 w-5 text-[var(--color-accent-primary)]" />
diff --git a/packages/web/src/app/repos/[id]/wiki/[...slug]/page.tsx b/packages/web/src/app/repos/[id]/wiki/[...slug]/page.tsx
index 978199847..4d4ad4073 100644
--- a/packages/web/src/app/repos/[id]/wiki/[...slug]/page.tsx
+++ b/packages/web/src/app/repos/[id]/wiki/[...slug]/page.tsx
@@ -11,6 +11,7 @@ import { GitHistoryPanel } from "@/components/wiki/git-history-panel";
import { Badge } from "@/components/ui/badge";
import { Separator } from "@/components/ui/separator";
import { formatRelativeTime, formatTokens } from "@/lib/utils/format";
+import { CoChangeList } from "@/components/git/co-change-list";
import { Hash, Cpu } from "lucide-react";
interface Props {
@@ -63,7 +64,7 @@ export default async function WikiPageRoute({ params }: Props) {
<span className="hidden sm:block">/</span>
</>
)}
- <span className="font-mono truncate text-[var(--color-text-secondary)] max-w-[180px] sm:max-w-none">
+ <span className="font-mono truncate text-[var(--color-text-secondary)] max-w-[180px] sm:max-w-none" title={page.target_path || page.page_type}>
{page.target_path || page.page_type}
</span>
</div>
@@ -78,7 +79,7 @@ export default async function WikiPageRoute({ params }: Props) {
{/* Provider badge */}
<Badge variant="outline" className="font-mono text-xs hidden sm:flex shrink-0">
<Cpu className="h-3 w-3 mr-1" />
- <span className="truncate max-w-[120px]">{page.provider_name}/{page.model_name}</span>
+ <span className="truncate max-w-[200px]" title={`${page.provider_name}/${page.model_name}`}>{page.provider_name}/{page.model_name}</span>
</Badge>
{/* Commit */}
@@ -156,26 +157,7 @@ export default async function WikiPageRoute({ params }: Props) {
</div>
)}
- {/* Co-change partners */}
- {git && git.co_change_partners.length > 0 && (
- <div>
- <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
- Co-change Partners
- </p>
- <ul className="space-y-1.5">
- {git.co_change_partners.slice(0, 5).map((p) => (
- <li key={p.file_path} className="text-xs min-w-0">
- <span className="font-mono text-[var(--color-text-secondary)] block truncate">
- {p.file_path}
- </span>
- <span className="text-[var(--color-text-tertiary)]">
- {p.co_change_count}× together
- </span>
- </li>
- ))}
- </ul>
- </div>
- )}
+ {/* Co-change partners — now uses the visual bar component */}
{/* Page metadata */}
<div>
diff --git a/packages/web/src/components/coverage/freshness-table.tsx b/packages/web/src/components/coverage/freshness-table.tsx
index 50a3bd8b3..d5493d486 100644
--- a/packages/web/src/components/coverage/freshness-table.tsx
+++ b/packages/web/src/components/coverage/freshness-table.tsx
@@ -64,7 +64,7 @@ export function FreshnessTable({ pages }: FreshnessTableProps) {
<EmptyState title="No pages" description="No pages match this filter." />
) : (
<div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
- <table className="w-full min-w-[560px] text-sm">
+ <table className="w-full text-sm">
<thead>
<tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
<th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
@@ -93,8 +93,8 @@ export function FreshnessTable({ pages }: FreshnessTableProps) {
key={page.id}
className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"
>
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)] max-w-xs">
- <div className="truncate">{truncatePath(page.target_path, 50)}</div>
+ <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)]" style={{ maxWidth: 0 }}>
+ <div className="truncate" title={page.target_path}>{page.target_path}</div>
<div className="text-[var(--color-text-tertiary)]">{page.page_type}</div>
</td>
<td className="px-4 py-2.5">
diff --git a/packages/web/src/components/dead-code/finding-row.tsx b/packages/web/src/components/dead-code/finding-row.tsx
index e3d89684d..2afc13d4f 100644
--- a/packages/web/src/components/dead-code/finding-row.tsx
+++ b/packages/web/src/components/dead-code/finding-row.tsx
@@ -50,8 +50,8 @@ export function FindingRow({ finding, selected, onToggle, onUpdate }: FindingRow
className="rounded border-[var(--color-border-default)]"
/>
</td>
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)] max-w-xs">
- <span className="truncate block">{truncatePath(finding.file_path, 50)}</span>
+ <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)]" style={{ maxWidth: 0 }}>
+ <span className="truncate block" title={finding.file_path}>{finding.file_path}</span>
{finding.symbol_name && (
<span className="text-[var(--color-text-tertiary)]">{finding.symbol_name}</span>
)}
diff --git a/packages/web/src/components/decisions/decision-detail.tsx b/packages/web/src/components/decisions/decision-detail.tsx
index e7e9d86a1..0012be346 100644
--- a/packages/web/src/components/decisions/decision-detail.tsx
+++ b/packages/web/src/components/decisions/decision-detail.tsx
@@ -88,7 +88,7 @@ export function DecisionDetail({ decision, repoId }: DecisionDetailProps) {
</h3>
<ul className="space-y-1 text-sm text-[var(--color-text-tertiary)]">
{decision.affected_files.slice(0, 10).map((f) => (
- <li key={f} className="truncate font-mono text-xs">{f}</li>
+ <li key={f} className="truncate font-mono text-xs" title={f}>{f}</li>
))}
{decision.affected_files.length > 10 && (
<li className="text-xs">...and {decision.affected_files.length - 10} more</li>
diff --git a/packages/web/src/components/decisions/decisions-table.tsx b/packages/web/src/components/decisions/decisions-table.tsx
index 45fda9300..bf9445d1d 100644
--- a/packages/web/src/components/decisions/decisions-table.tsx
+++ b/packages/web/src/components/decisions/decisions-table.tsx
@@ -91,10 +91,11 @@ export function DecisionsTable({ repoId, initialData }: DecisionsTableProps) {
d.status === "proposed" ? "border-l-2 border-l-amber-400" : ""
}`}
>
- <td className="px-4 py-2.5">
+ <td className="px-4 py-2.5" style={{ maxWidth: 0 }}>
<Link
href={`/repos/${repoId}/decisions/${d.id}`}
- className="font-medium text-[var(--color-accent-primary)] hover:underline"
+ className="font-medium text-[var(--color-accent-primary)] hover:underline block truncate"
+ title={d.title}
>
{d.title}
</Link>
diff --git a/packages/web/src/components/git/bus-factor-panel.tsx b/packages/web/src/components/git/bus-factor-panel.tsx
new file mode 100644
index 000000000..e2a2de21d
--- /dev/null
+++ b/packages/web/src/components/git/bus-factor-panel.tsx
@@ -0,0 +1,98 @@
+"use client";
+
+import {
+ BarChart,
+ Bar,
+ XAxis,
+ Tooltip,
+ ResponsiveContainer,
+} from "recharts";
+import { truncatePath } from "@/lib/utils/format";
+import type { HotspotResponse } from "@/lib/api/types";
+
+interface BusFactorPanelProps {
+ hotspots: HotspotResponse[];
+}
+
+export function BusFactorPanel({ hotspots }: BusFactorPanelProps) {
+ const high = hotspots.filter((h) => h.bus_factor >= 3).length;
+ const medium = hotspots.filter((h) => h.bus_factor === 2).length;
+ const low = hotspots.filter((h) => h.bus_factor <= 1).length;
+ const total = hotspots.length || 1;
+
+ const data = [{ high, medium, low }];
+
+ const riskFiles = hotspots
+ .filter((h) => h.bus_factor <= 1)
+ .sort((a, b) => b.commit_count_90d - a.commit_count_90d)
+ .slice(0, 5);
+
+ return (
+ <div className="space-y-4">
+ {/* Stacked bar */}
+ <div>
+ <div className="flex items-center justify-between text-xs text-[var(--color-text-tertiary)] mb-2">
+ <span>Bus Factor Distribution</span>
+ <span>{hotspots.length} files</span>
+ </div>
+ <ResponsiveContainer width="100%" height={36}>
+ <BarChart layout="vertical" data={data} margin={{ top: 0, right: 0, bottom: 0, left: 0 }}>
+ <XAxis type="number" hide domain={[0, total]} />
+ <Tooltip
+ cursor={false}
+ contentStyle={{
+ background: "var(--color-bg-overlay)",
+ border: "1px solid var(--color-border-default)",
+ borderRadius: "6px",
+ fontSize: "12px",
+ color: "var(--color-text-primary)",
+ }}
+ formatter={(value: number, name: string) => {
+ const label = name === "high" ? "Safe (≥3)" : name === "medium" ? "Warning (2)" : "Risk (≤1)";
+ return [`${value} files`, label];
+ }}
+ />
+ <Bar dataKey="high" stackId="a" fill="#22c55e" radius={[4, 0, 0, 4]} />
+ <Bar dataKey="medium" stackId="a" fill="#eab308" />
+ <Bar dataKey="low" stackId="a" fill="#ef4444" radius={[0, 4, 4, 0]} />
+ </BarChart>
+ </ResponsiveContainer>
+ <div className="flex items-center gap-4 mt-2 text-[10px] text-[var(--color-text-tertiary)]">
+ <span className="flex items-center gap-1">
+ <span className="inline-block h-2 w-2 rounded-sm bg-green-500" /> Safe (≥3): {high}
+ </span>
+ <span className="flex items-center gap-1">
+ <span className="inline-block h-2 w-2 rounded-sm bg-yellow-500" /> Warning (2): {medium}
+ </span>
+ <span className="flex items-center gap-1">
+ <span className="inline-block h-2 w-2 rounded-sm bg-red-500" /> Risk (≤1): {low}
+ </span>
+ </div>
+ </div>
+
+ {/* At-risk files list */}
+ {riskFiles.length > 0 && (
+ <div>
+ <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
+ Highest Risk Files
+ </p>
+ <div className="space-y-1.5">
+ {riskFiles.map((f) => (
+ <div
+ key={f.file_path}
+ className="flex items-center justify-between text-xs rounded-md px-2 py-1.5 bg-[var(--color-bg-elevated)]"
+ >
+ <span className="font-mono text-[var(--color-text-primary)] truncate flex-1 min-w-0" title={f.file_path}>
+ {truncatePath(f.file_path)}
+ </span>
+ <span className="text-[var(--color-text-tertiary)] tabular-nums ml-2 shrink-0">
+ {f.contributor_count} contributor{f.contributor_count !== 1 ? "s" : ""}
+ </span>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/packages/web/src/components/git/churn-histogram.tsx b/packages/web/src/components/git/churn-histogram.tsx
new file mode 100644
index 000000000..5f68b9859
--- /dev/null
+++ b/packages/web/src/components/git/churn-histogram.tsx
@@ -0,0 +1,71 @@
+"use client";
+
+import {
+ BarChart,
+ Bar,
+ XAxis,
+ YAxis,
+ Tooltip,
+ ResponsiveContainer,
+ Cell,
+} from "recharts";
+import type { HotspotResponse } from "@/lib/api/types";
+
+interface ChurnHistogramProps {
+ hotspots: HotspotResponse[];
+}
+
+const BUCKET_COLORS = [
+ "#22c55e", "#22c55e", "#22c55e", "#22c55e", "#22c55e",
+ "#eab308", "#eab308", "#f59520",
+ "#ef4444", "#ef4444",
+];
+
+export function ChurnHistogram({ hotspots }: ChurnHistogramProps) {
+ const buckets = Array(10).fill(0) as number[];
+ for (const h of hotspots) {
+ const idx = Math.min(9, Math.floor(h.churn_percentile / 10));
+ buckets[idx]++;
+ }
+
+ const data = buckets.map((count, i) => ({
+ range: `${i * 10}–${(i + 1) * 10}`,
+ count,
+ }));
+
+ return (
+ <ResponsiveContainer width="100%" height={200}>
+ <BarChart data={data} margin={{ top: 8, right: 8, bottom: 0, left: -16 }}>
+ <XAxis
+ dataKey="range"
+ tick={{ fill: "var(--color-text-tertiary)", fontSize: 10 }}
+ axisLine={false}
+ tickLine={false}
+ />
+ <YAxis
+ tick={{ fill: "var(--color-text-tertiary)", fontSize: 10 }}
+ axisLine={false}
+ tickLine={false}
+ allowDecimals={false}
+ />
+ <Tooltip
+ cursor={{ fill: "var(--color-bg-elevated)" }}
+ contentStyle={{
+ background: "var(--color-bg-overlay)",
+ border: "1px solid var(--color-border-default)",
+ borderRadius: "6px",
+ fontSize: "12px",
+ color: "var(--color-text-primary)",
+ }}
+ formatter={(value: number) => [`${value} files`, "Count"]}
+ labelFormatter={(label: string) => `Churn ${label}%`}
+ />
+ <Bar dataKey="count" radius={[4, 4, 0, 0]}>
+ {data.map((_, i) => (
+ <Cell key={i} fill={BUCKET_COLORS[i]} />
+ ))}
+ </Bar>
+ </BarChart>
+ </ResponsiveContainer>
+ );
+}
diff --git a/packages/web/src/components/git/co-change-list.tsx b/packages/web/src/components/git/co-change-list.tsx
new file mode 100644
index 000000000..8a62d42f3
--- /dev/null
+++ b/packages/web/src/components/git/co-change-list.tsx
@@ -0,0 +1,36 @@
+import { truncatePath } from "@/lib/utils/format";
+
+interface CoChangeListProps {
+ partners: Array<{ file_path: string; co_change_count: number }>;
+}
+
+export function CoChangeList({ partners }: CoChangeListProps) {
+ if (partners.length === 0) return null;
+
+ const maxCount = Math.max(...partners.map((p) => p.co_change_count));
+
+ return (
+ <div className="space-y-1.5">
+ {partners.slice(0, 5).map((p) => (
+ <div key={p.file_path} className="space-y-0.5">
+ <div className="flex items-center justify-between text-xs">
+ <span className="font-mono text-[var(--color-text-secondary)] truncate flex-1 min-w-0" title={p.file_path}>
+ {truncatePath(p.file_path, 45)}
+ </span>
+ <span className="text-[var(--color-text-tertiary)] tabular-nums shrink-0 ml-1">
+ {p.co_change_count}&times;
+ </span>
+ </div>
+ <div className="h-1 w-full rounded-full bg-[var(--color-bg-elevated)]">
+ <div
+ className="h-1 rounded-full bg-[var(--color-accent-primary)] transition-all"
+ style={{
+ width: `${maxCount > 0 ? (p.co_change_count / maxCount) * 100 : 0}%`,
+ }}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ );
+}
diff --git a/packages/web/src/components/git/commit-category-donut.tsx b/packages/web/src/components/git/commit-category-donut.tsx
new file mode 100644
index 000000000..d73f93942
--- /dev/null
+++ b/packages/web/src/components/git/commit-category-donut.tsx
@@ -0,0 +1,78 @@
+"use client";
+
+import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from "recharts";
+
+interface CommitCategoryDonutProps {
+ categories: Record<string, number>;
+}
+
+const CATEGORY_COLORS: Record<string, string> = {
+ feature: "#5b9cf6",
+ fix: "#ef4444",
+ refactor: "#a855f7",
+ dependency: "#f59520",
+};
+
+const CATEGORY_ORDER = ["feature", "fix", "refactor", "dependency"];
+
+export function CommitCategoryDonut({ categories }: CommitCategoryDonutProps) {
+ const data = CATEGORY_ORDER.map((key) => ({
+ name: key.charAt(0).toUpperCase() + key.slice(1),
+ value: categories[key] || 0,
+ key,
+ })).filter((d) => d.value > 0);
+
+ const total = data.reduce((sum, d) => sum + d.value, 0);
+ if (total === 0) return null;
+
+ const dominant = data.reduce((a, b) => (a.value >= b.value ? a : b));
+
+ return (
+ <div className="relative flex items-center justify-center">
+ <ResponsiveContainer width={180} height={180}>
+ <PieChart>
+ <Pie
+ data={data}
+ cx="50%"
+ cy="50%"
+ innerRadius={50}
+ outerRadius={75}
+ paddingAngle={2}
+ dataKey="value"
+ startAngle={90}
+ endAngle={-270}
+ >
+ {data.map((entry) => (
+ <Cell
+ key={entry.key}
+ fill={CATEGORY_COLORS[entry.key] || "#8b5cf6"}
+ strokeWidth={0}
+ />
+ ))}
+ </Pie>
+ <Tooltip
+ contentStyle={{
+ background: "var(--color-bg-overlay)",
+ border: "1px solid var(--color-border-default)",
+ borderRadius: "6px",
+ fontSize: "12px",
+ color: "var(--color-text-primary)",
+ }}
+ formatter={(value: number, name: string) => [
+ `${value} commits (${Math.round((value / total) * 100)}%)`,
+ name,
+ ]}
+ />
+ </PieChart>
+ </ResponsiveContainer>
+ <div className="absolute flex flex-col items-center pointer-events-none">
+ <span className="text-lg font-bold text-[var(--color-text-primary)] tabular-nums">
+ {Math.round((dominant.value / total) * 100)}%
+ </span>
+ <span className="text-[10px] text-[var(--color-text-tertiary)] capitalize">
+ {dominant.name}
+ </span>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/web/src/components/git/commit-category-sparkline.tsx b/packages/web/src/components/git/commit-category-sparkline.tsx
new file mode 100644
index 000000000..33cdf6e9b
--- /dev/null
+++ b/packages/web/src/components/git/commit-category-sparkline.tsx
@@ -0,0 +1,51 @@
+import {
+ Tooltip,
+ TooltipTrigger,
+ TooltipContent,
+} from "@/components/ui/tooltip";
+
+interface CommitCategorySparklineProps {
+ categories: Record<string, number>;
+}
+
+const CATEGORY_CONFIG: Record<string, { color: string; label: string }> = {
+ feature: { color: "#5b9cf6", label: "Feature" },
+ fix: { color: "#ef4444", label: "Fix" },
+ refactor: { color: "#a855f7", label: "Refactor" },
+ dependency: { color: "#f59520", label: "Dependency" },
+};
+
+const CATEGORY_ORDER = ["feature", "fix", "refactor", "dependency"];
+
+export function CommitCategorySparkline({ categories }: CommitCategorySparklineProps) {
+ const total = CATEGORY_ORDER.reduce((sum, k) => sum + (categories[k] || 0), 0);
+ if (total === 0) return null;
+
+ return (
+ <div className="flex h-2 w-full rounded-full overflow-hidden bg-[var(--color-bg-elevated)]">
+ {CATEGORY_ORDER.map((key) => {
+ const count = categories[key] || 0;
+ if (count === 0) return null;
+ const config = CATEGORY_CONFIG[key];
+ return (
+ <Tooltip key={key}>
+ <TooltipTrigger asChild>
+ <div
+ className="h-full transition-all"
+ style={{
+ flex: count,
+ backgroundColor: config.color,
+ }}
+ />
+ </TooltipTrigger>
+ <TooltipContent>
+ <span className="text-xs">
+ {config.label}: {count} ({Math.round((count / total) * 100)}%)
+ </span>
+ </TooltipContent>
+ </Tooltip>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/packages/web/src/components/git/contributor-bar.tsx b/packages/web/src/components/git/contributor-bar.tsx
index c07d516ae..55d528543 100644
--- a/packages/web/src/components/git/contributor-bar.tsx
+++ b/packages/web/src/components/git/contributor-bar.tsx
@@ -10,7 +10,7 @@ import {
} from "recharts";
interface ContributorBarProps {
- owners: Array<{ name: string; email: string; file_count: number; pct: number }>;
+ owners: Array<{ name: string; email?: string; file_count: number; pct: number }>;
}
export function ContributorBar({ owners }: ContributorBarProps) {
diff --git a/packages/web/src/components/git/hotspot-table.tsx b/packages/web/src/components/git/hotspot-table.tsx
index 2fce0019d..07032ed64 100644
--- a/packages/web/src/components/git/hotspot-table.tsx
+++ b/packages/web/src/components/git/hotspot-table.tsx
@@ -1,14 +1,52 @@
+"use client";
+
+import { useState, useMemo } from "react";
+import { TrendingUp, TrendingDown, Search } from "lucide-react";
import { Badge } from "@/components/ui/badge";
+import { Input } from "@/components/ui/input";
import { EmptyState } from "@/components/shared/empty-state";
import { ChurnBar } from "./churn-bar";
-import { truncatePath } from "@/lib/utils/format";
+import { formatLOC } from "@/lib/utils/format";
+import { cn } from "@/lib/utils/cn";
import type { HotspotResponse } from "@/lib/api/types";
interface HotspotTableProps {
hotspots: HotspotResponse[];
}
+type Filter = "all" | "hot" | "risk" | "accelerating";
+
export function HotspotTable({ hotspots }: HotspotTableProps) {
+ const [search, setSearch] = useState("");
+ const [filter, setFilter] = useState<Filter>("all");
+
+ const filtered = useMemo(() => {
+ let items = hotspots;
+
+ if (search) {
+ const q = search.toLowerCase();
+ items = items.filter(
+ (h) =>
+ h.file_path.toLowerCase().includes(q) ||
+ (h.primary_owner ?? "").toLowerCase().includes(q),
+ );
+ }
+
+ switch (filter) {
+ case "hot":
+ items = items.filter((h) => h.is_hotspot);
+ break;
+ case "risk":
+ items = items.filter((h) => h.bus_factor <= 1);
+ break;
+ case "accelerating":
+ items = items.filter((h) => h.commit_count_30d * 3 > h.commit_count_90d);
+ break;
+ }
+
+ return items;
+ }, [hotspots, search, filter]);
+
if (hotspots.length === 0) {
return (
<EmptyState
@@ -18,62 +56,143 @@ export function HotspotTable({ hotspots }: HotspotTableProps) {
);
}
+ const filters: { key: Filter; label: string; count: number }[] = [
+ { key: "all", label: "All", count: hotspots.length },
+ { key: "hot", label: "Hot", count: hotspots.filter((h) => h.is_hotspot).length },
+ { key: "risk", label: "Bus factor risk", count: hotspots.filter((h) => h.bus_factor <= 1).length },
+ { key: "accelerating", label: "Accelerating", count: hotspots.filter((h) => h.commit_count_30d * 3 > h.commit_count_90d).length },
+ ];
+
return (
- <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
- <table className="w-full min-w-[560px] text-sm">
- <thead>
- <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-8">
- #
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- File
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-28">
- Commits 90d
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-36">
- Churn
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- Owner
- </th>
- <th className="px-4 py-2.5 w-16" />
- </tr>
- </thead>
- <tbody>
- {hotspots.map((h, i) => (
- <tr
- key={h.file_path}
- className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"
+ <div className="space-y-3">
+ {/* Search + filters */}
+ <div className="flex flex-wrap items-center gap-2">
+ <div className="relative">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--color-text-tertiary)]" />
+ <Input
+ placeholder="Search files or owners…"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ className="pl-8 h-8 w-56 text-xs"
+ />
+ </div>
+ <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">
+ {filters.map((f) => (
+ <button
+ key={f.key}
+ onClick={() => setFilter(f.key)}
+ className={cn(
+ "px-2.5 py-1.5 font-medium transition-colors",
+ filter === f.key
+ ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"
+ : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",
+ )}
>
- <td className="px-4 py-2.5 text-[var(--color-text-tertiary)] tabular-nums text-xs">
- {i + 1}
- </td>
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)] max-w-xs truncate">
- {truncatePath(h.file_path, 60)}
- </td>
- <td className="px-4 py-2.5 tabular-nums text-[var(--color-text-secondary)] text-xs">
- {h.commit_count_90d}
- </td>
- <td className="px-4 py-2.5">
- <div className="flex items-center gap-2">
- <ChurnBar percentile={h.churn_percentile} className="w-20" />
- <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
- {Math.round(h.churn_percentile)}%
- </span>
- </div>
- </td>
- <td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)]">
- {h.primary_owner ?? "—"}
- </td>
- <td className="px-4 py-2.5">
- {h.is_hotspot && <Badge variant="outdated">Hot</Badge>}
- </td>
- </tr>
+ {f.label}
+ <span className="ml-1 text-[10px] opacity-70">({f.count})</span>
+ </button>
))}
- </tbody>
- </table>
+ </div>
+ </div>
+
+ {/* Table */}
+ {filtered.length === 0 ? (
+ <EmptyState title="No matches" description="Try adjusting your search or filters." />
+ ) : (
+ <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-8">
+ #
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
+ File
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24">
+ Commits 90d
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-32">
+ Churn
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-20">
+ Bus Factor
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24">
+ Lines ±90d
+ </th>
+ <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
+ Owner
+ </th>
+ <th className="px-3 py-2.5 w-20" />
+ </tr>
+ </thead>
+ <tbody>
+ {filtered.map((h, i) => {
+ const accelerating = h.commit_count_30d * 3 > h.commit_count_90d;
+ return (
+ <tr
+ key={h.file_path}
+ className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"
+ >
+ <td className="px-3 py-2.5 text-[var(--color-text-tertiary)] tabular-nums text-xs">
+ {i + 1}
+ </td>
+ <td className="px-3 py-2.5 font-mono text-xs text-[var(--color-text-primary)]" style={{ maxWidth: 0 }}>
+ <span className="block truncate" title={h.file_path}>{h.file_path}</span>
+ </td>
+ <td className="px-3 py-2.5 tabular-nums text-xs">
+ <span className="flex items-center gap-1">
+ <span className="text-[var(--color-text-secondary)]">
+ {h.commit_count_90d}
+ </span>
+ {accelerating ? (
+ <TrendingUp className="h-3 w-3 text-red-500" />
+ ) : (
+ <TrendingDown className="h-3 w-3 text-green-500" />
+ )}
+ </span>
+ </td>
+ <td className="px-3 py-2.5">
+ <div className="flex items-center gap-2">
+ <ChurnBar percentile={h.churn_percentile} className="w-16" />
+ <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
+ {Math.round(h.churn_percentile)}%
+ </span>
+ </div>
+ </td>
+ <td className="px-3 py-2.5">
+ <span
+ className={`inline-flex items-center justify-center rounded px-1.5 py-0.5 text-xs font-medium tabular-nums ${
+ h.bus_factor <= 1
+ ? "bg-red-500/15 text-red-400"
+ : h.bus_factor === 2
+ ? "bg-yellow-500/15 text-yellow-400"
+ : "bg-green-500/15 text-green-400"
+ }`}
+ >
+ {h.bus_factor}
+ </span>
+ </td>
+ <td className="px-3 py-2.5 text-xs tabular-nums">
+ <span className="text-green-400">+{formatLOC(h.lines_added_90d)}</span>
+ {" "}
+ <span className="text-red-400">-{formatLOC(h.lines_deleted_90d)}</span>
+ </td>
+ <td className="px-3 py-2.5 text-xs text-[var(--color-text-secondary)]">
+ {h.primary_owner ?? "—"}
+ </td>
+ <td className="px-3 py-2.5 flex items-center gap-1">
+ {h.is_hotspot && <Badge variant="outdated">Hot</Badge>}
+ {h.is_stable && <Badge variant="fresh">Stable</Badge>}
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </div>
+ )}
</div>
);
}
diff --git a/packages/web/src/components/git/ownership-table.tsx b/packages/web/src/components/git/ownership-table.tsx
index 88986b35f..495b85375 100644
--- a/packages/web/src/components/git/ownership-table.tsx
+++ b/packages/web/src/components/git/ownership-table.tsx
@@ -1,14 +1,43 @@
+"use client";
+
+import { useState, useMemo } from "react";
+import { Search } from "lucide-react";
import { Badge } from "@/components/ui/badge";
+import { Input } from "@/components/ui/input";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { EmptyState } from "@/components/shared/empty-state";
-import { truncatePath } from "@/lib/utils/format";
+import { cn } from "@/lib/utils/cn";
import type { OwnershipEntry } from "@/lib/api/types";
interface OwnershipTableProps {
entries: OwnershipEntry[];
}
+type Filter = "all" | "silo";
+
export function OwnershipTable({ entries }: OwnershipTableProps) {
+ const [search, setSearch] = useState("");
+ const [filter, setFilter] = useState<Filter>("all");
+
+ const filtered = useMemo(() => {
+ let items = entries;
+
+ if (search) {
+ const q = search.toLowerCase();
+ items = items.filter(
+ (e) =>
+ e.module_path.toLowerCase().includes(q) ||
+ (e.primary_owner ?? "").toLowerCase().includes(q),
+ );
+ }
+
+ if (filter === "silo") {
+ items = items.filter((e) => e.is_silo);
+ }
+
+ return items;
+ }, [entries, search, filter]);
+
if (entries.length === 0) {
return (
<EmptyState
@@ -18,74 +47,122 @@ export function OwnershipTable({ entries }: OwnershipTableProps) {
);
}
+ const siloCount = entries.filter((e) => e.is_silo).length;
+
return (
- <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
- <table className="w-full min-w-[520px] text-sm">
- <thead>
- <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- Module / File
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- Owner
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-36">
- Ownership
- </th>
- <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-16">
- Files
- </th>
- <th className="px-4 py-2.5 w-20" />
- </tr>
- </thead>
- <tbody>
- {entries.map((entry) => (
- <tr
- key={entry.module_path}
- className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"
- >
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)] max-w-xs truncate">
- {truncatePath(entry.module_path, 60)}
- </td>
- <td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)]">
- {entry.primary_owner ?? "—"}
- </td>
- <td className="px-4 py-2.5">
- {entry.owner_pct !== null ? (
- <div className="flex items-center gap-2">
- <div className="h-1.5 flex-1 rounded-full bg-[var(--color-bg-elevated)]">
- <div
- className="h-1.5 rounded-full bg-[var(--color-accent-primary)]"
- style={{ width: `${Math.min(100, entry.owner_pct * 100)}%` }}
- />
- </div>
- <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
- {Math.round(entry.owner_pct * 100)}%
- </span>
- </div>
- ) : (
- <span className="text-[var(--color-text-tertiary)]">—</span>
- )}
- </td>
- <td className="px-4 py-2.5 text-xs text-[var(--color-text-tertiary)] tabular-nums">
- {entry.file_count}
- </td>
- <td className="px-4 py-2.5">
- {entry.is_silo && (
- <Tooltip>
- <TooltipTrigger asChild>
- <span>
- <Badge variant="stale">Silo</Badge>
- </span>
- </TooltipTrigger>
- <TooltipContent>Bus factor risk</TooltipContent>
- </Tooltip>
- )}
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <div className="space-y-3">
+ {/* Search + filters */}
+ <div className="flex flex-wrap items-center gap-2">
+ <div className="relative">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--color-text-tertiary)]" />
+ <Input
+ placeholder="Search modules or owners…"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ className="pl-8 h-8 w-56 text-xs"
+ />
+ </div>
+ <div className="flex rounded-md border border-[var(--color-border-default)] overflow-hidden text-xs">
+ <button
+ onClick={() => setFilter("all")}
+ className={cn(
+ "px-2.5 py-1.5 font-medium transition-colors",
+ filter === "all"
+ ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"
+ : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",
+ )}
+ >
+ All <span className="text-[10px] opacity-70">({entries.length})</span>
+ </button>
+ <button
+ onClick={() => setFilter("silo")}
+ className={cn(
+ "px-2.5 py-1.5 font-medium transition-colors",
+ filter === "silo"
+ ? "bg-[var(--color-accent-primary)] text-[var(--color-text-inverse)]"
+ : "bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)]",
+ )}
+ >
+ Silos <span className="text-[10px] opacity-70">({siloCount})</span>
+ </button>
+ </div>
+ <span className="text-xs text-[var(--color-text-tertiary)]">
+ {filtered.length} {filtered.length === 1 ? "entry" : "entries"}
+ </span>
+ </div>
+
+ {filtered.length === 0 ? (
+ <EmptyState title="No matches" description="Try adjusting your search or filters." />
+ ) : (
+ <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
+ <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
+ Module / File
+ </th>
+ <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
+ Owner
+ </th>
+ <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-36">
+ Ownership
+ </th>
+ <th className="px-4 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-16">
+ Files
+ </th>
+ <th className="px-4 py-2.5 w-20" />
+ </tr>
+ </thead>
+ <tbody>
+ {filtered.map((entry) => (
+ <tr
+ key={entry.module_path}
+ className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0"
+ >
+ <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)]" style={{ maxWidth: 0 }}>
+ <span className="block truncate" title={entry.module_path}>{entry.module_path}</span>
+ </td>
+ <td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)]">
+ {entry.primary_owner ?? "—"}
+ </td>
+ <td className="px-4 py-2.5">
+ {entry.owner_pct !== null ? (
+ <div className="flex items-center gap-2">
+ <div className="h-1.5 flex-1 rounded-full bg-[var(--color-bg-elevated)]">
+ <div
+ className="h-1.5 rounded-full bg-[var(--color-accent-primary)]"
+ style={{ width: `${Math.min(100, entry.owner_pct * 100)}%` }}
+ />
+ </div>
+ <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
+ {Math.round(entry.owner_pct * 100)}%
+ </span>
+ </div>
+ ) : (
+ <span className="text-[var(--color-text-tertiary)]">—</span>
+ )}
+ </td>
+ <td className="px-4 py-2.5 text-xs text-[var(--color-text-tertiary)] tabular-nums">
+ {entry.file_count}
+ </td>
+ <td className="px-4 py-2.5">
+ {entry.is_silo && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Badge variant="stale">Silo</Badge>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>Bus factor risk</TooltipContent>
+ </Tooltip>
+ )}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ )}
</div>
);
}
diff --git a/packages/web/src/components/git/ownership-treemap.tsx b/packages/web/src/components/git/ownership-treemap.tsx
new file mode 100644
index 000000000..92fa795f5
--- /dev/null
+++ b/packages/web/src/components/git/ownership-treemap.tsx
@@ -0,0 +1,189 @@
+"use client";
+
+import { useRef, useEffect, useState, useCallback } from "react";
+import { hierarchy, treemap, treemapSquarify, type HierarchyRectangularNode } from "d3-hierarchy";
+import type { OwnershipEntry } from "@/lib/api/types";
+
+interface OwnershipTreemapProps {
+ entries: OwnershipEntry[];
+}
+
+const OWNER_COLORS = [
+ "#5b9cf6", "#a855f7", "#22c55e", "#eab308",
+ "#ec4899", "#6366f1", "#14b8a6", "#f59520",
+];
+
+function ownerColor(name: string | null): string {
+ if (!name) return "#4b5563";
+ let hash = 0;
+ for (let i = 0; i < name.length; i++) {
+ hash = name.charCodeAt(i) + ((hash << 5) - hash);
+ }
+ return OWNER_COLORS[Math.abs(hash) % OWNER_COLORS.length];
+}
+
+interface TooltipData {
+ x: number;
+ y: number;
+ name: string;
+ owner: string | null;
+ fileCount: number;
+ pct: number | null;
+ isSilo: boolean;
+}
+
+export function OwnershipTreemap({ entries }: OwnershipTreemapProps) {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const [dims, setDims] = useState({ width: 600, height: 320 });
+ const [tooltip, setTooltip] = useState<TooltipData | null>(null);
+
+ useEffect(() => {
+ const el = containerRef.current;
+ if (!el) return;
+ const ro = new ResizeObserver((entries) => {
+ const { width } = entries[0].contentRect;
+ if (width > 0) setDims({ width, height: Math.max(240, Math.min(400, width * 0.5)) });
+ });
+ ro.observe(el);
+ return () => ro.disconnect();
+ }, []);
+
+ const handleMouseMove = useCallback(
+ (e: React.MouseEvent, d: { name: string; owner: string | null; fileCount: number; pct: number | null; isSilo: boolean }) => {
+ const rect = containerRef.current?.getBoundingClientRect();
+ if (!rect) return;
+ setTooltip({
+ x: e.clientX - rect.left,
+ y: e.clientY - rect.top,
+ ...d,
+ });
+ },
+ [],
+ );
+
+ if (entries.length === 0) return null;
+
+ interface TreemapLeaf {
+ name: string;
+ value?: number;
+ owner?: string | null;
+ pct?: number | null;
+ isSilo?: boolean;
+ children?: TreemapLeaf[];
+ }
+
+ const root = hierarchy<TreemapLeaf>({
+ name: "root",
+ children: entries.map((e) => ({
+ name: e.module_path,
+ value: e.file_count,
+ owner: e.primary_owner,
+ pct: e.owner_pct,
+ isSilo: e.is_silo,
+ })),
+ })
+ .sum((d) => d.value || 0)
+ .sort((a, b) => (b.value || 0) - (a.value || 0));
+
+ treemap<TreemapLeaf>()
+ .size([dims.width, dims.height])
+ .padding(2)
+ .tile(treemapSquarify)(root);
+
+ const leaves = root.leaves() as HierarchyRectangularNode<TreemapLeaf>[];
+
+ return (
+ <div ref={containerRef} className="relative w-full">
+ <svg
+ width={dims.width}
+ height={dims.height}
+ className="rounded-lg"
+ onMouseLeave={() => setTooltip(null)}
+ >
+ {leaves.map((leaf) => {
+ const d = leaf.data;
+ const x0 = leaf.x0;
+ const y0 = leaf.y0;
+ const w = leaf.x1 - x0;
+ const h = leaf.y1 - y0;
+ const showLabel = w > 50 && h > 28;
+
+ return (
+ <g
+ key={d.name}
+ onMouseMove={(e) =>
+ handleMouseMove(e, {
+ name: d.name,
+ owner: d.owner ?? null,
+ fileCount: leaf.value || 0,
+ pct: d.pct ?? null,
+ isSilo: d.isSilo ?? false,
+ })
+ }
+ onMouseLeave={() => setTooltip(null)}
+ >
+ <rect
+ x={x0}
+ y={y0}
+ width={w}
+ height={h}
+ fill={ownerColor(d.owner ?? null)}
+ opacity={0.8}
+ rx={3}
+ stroke={d.isSilo ? "#f59520" : "none"}
+ strokeWidth={d.isSilo ? 2 : 0}
+ strokeDasharray={d.isSilo ? "4 2" : "none"}
+ className="transition-opacity hover:opacity-100"
+ />
+ {showLabel && (
+ <>
+ <text
+ x={x0 + 6}
+ y={y0 + 14}
+ fill="#fff"
+ fontSize={11}
+ fontWeight={600}
+ fontFamily="var(--font-geist-mono)"
+ pointerEvents="none"
+ >
+ {d.name.length > w / 7 ? d.name.slice(0, Math.floor(w / 7)) + "…" : d.name}
+ </text>
+ <text
+ x={x0 + 6}
+ y={y0 + 27}
+ fill="rgba(255,255,255,0.7)"
+ fontSize={10}
+ pointerEvents="none"
+ >
+ {leaf.value} files
+ </text>
+ </>
+ )}
+ </g>
+ );
+ })}
+ </svg>
+
+ {/* Tooltip */}
+ {tooltip && (
+ <div
+ className="absolute z-20 pointer-events-none rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-overlay)] px-3 py-2 text-xs shadow-lg"
+ style={{
+ left: Math.min(tooltip.x + 12, dims.width - 180),
+ top: tooltip.y - 60,
+ }}
+ >
+ <p className="font-mono font-medium text-[var(--color-text-primary)]">{tooltip.name}</p>
+ <p className="text-[var(--color-text-secondary)] mt-0.5">
+ Owner: {tooltip.owner ?? "—"}
+ {tooltip.pct != null && ` (${Math.round(tooltip.pct * 100)}%)`}
+ </p>
+ <p className="text-[var(--color-text-secondary)]">{tooltip.fileCount} files</p>
+ {tooltip.isSilo && (
+ <p className="text-yellow-400 font-medium mt-0.5">Silo risk</p>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/packages/web/src/components/shared/stat-card.tsx b/packages/web/src/components/shared/stat-card.tsx
index e7def189a..fbe90f499 100644
--- a/packages/web/src/components/shared/stat-card.tsx
+++ b/packages/web/src/components/shared/stat-card.tsx
@@ -16,6 +16,7 @@ export function StatCard({
label,
value,
description,
+ trend,
icon,
className,
}: StatCardProps) {
@@ -27,9 +28,23 @@ export function StatCard({
<p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
{label}
</p>
- <p className="text-2xl font-bold text-[var(--color-text-primary)] tabular-nums">
- {value}
- </p>
+ <div className="flex items-baseline gap-2">
+ <p className="text-2xl font-bold text-[var(--color-text-primary)] tabular-nums">
+ {value}
+ </p>
+ {trend && (
+ <span
+ className={cn(
+ "text-xs font-medium tabular-nums",
+ trend.positive
+ ? "text-[var(--color-success)]"
+ : "text-[var(--color-error)]",
+ )}
+ >
+ {trend.positive ? "\u2191" : "\u2193"} {trend.value}
+ </span>
+ )}
+ </div>
{description && (
<p className="text-xs text-[var(--color-text-secondary)]">{description}</p>
)}
diff --git a/packages/web/src/components/symbols/symbol-table.tsx b/packages/web/src/components/symbols/symbol-table.tsx
index 29271d7a9..4a4b2099f 100644
--- a/packages/web/src/components/symbols/symbol-table.tsx
+++ b/packages/web/src/components/symbols/symbol-table.tsx
@@ -150,7 +150,7 @@ export function SymbolTable({ repoId }: SymbolTableProps) {
) : (
<>
<div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
- <table className="w-full min-w-[600px] text-sm">
+ <table className="w-full text-sm">
<thead>
<tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
{(
@@ -182,8 +182,8 @@ export function SymbolTable({ repoId }: SymbolTableProps) {
className="border-b border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] transition-colors last:border-0 cursor-pointer"
onClick={() => setSelected(sym)}
>
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)] max-w-xs">
- <span className="truncate block">{sym.name}</span>
+ <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-primary)]" style={{ maxWidth: 0 }}>
+ <span className="truncate block" title={sym.qualified_name || sym.name}>{sym.name}</span>
{sym.parent_name && (
<span className="text-[var(--color-text-tertiary)]">.{sym.parent_name}</span>
)}
@@ -194,9 +194,10 @@ export function SymbolTable({ repoId }: SymbolTableProps) {
<td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)]">
{sym.language}
</td>
- <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-tertiary)] max-w-xs truncate">
- {truncatePath(sym.file_path, 40)}
- <span className="text-[var(--color-text-tertiary)]">:{sym.start_line}</span>
+ <td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-tertiary)]" style={{ maxWidth: 0 }}>
+ <span className="block truncate" title={`${sym.file_path}:${sym.start_line}`}>
+ {truncatePath(sym.file_path)}:{sym.start_line}
+ </span>
</td>
<td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)] tabular-nums">
<span
diff --git a/packages/web/src/components/wiki/git-history-panel.tsx b/packages/web/src/components/wiki/git-history-panel.tsx
index 8c315fee2..efb997822 100644
--- a/packages/web/src/components/wiki/git-history-panel.tsx
+++ b/packages/web/src/components/wiki/git-history-panel.tsx
@@ -1,11 +1,30 @@
import { GitCommit, User } from "lucide-react";
-import { formatRelativeTime, truncatePath } from "@/lib/utils/format";
+import { Badge } from "@/components/ui/badge";
+import { CommitCategorySparkline } from "@/components/git/commit-category-sparkline";
+import { CoChangeList } from "@/components/git/co-change-list";
+import { formatRelativeTime, formatDate, formatAgeDays } from "@/lib/utils/format";
import type { GitMetadataResponse } from "@/lib/api/types";
interface GitHistoryPanelProps {
git: GitMetadataResponse;
}
+const AUTHOR_COLORS = [
+ "bg-blue-500", "bg-purple-500", "bg-green-500", "bg-yellow-500",
+ "bg-pink-500", "bg-indigo-500", "bg-teal-500", "bg-orange-500",
+];
+
+const AUTHOR_BAR_COLORS = [
+ "#3b82f6", "#a855f7", "#22c55e", "#eab308",
+ "#ec4899", "#6366f1", "#14b8a6", "#f97316",
+];
+
+function authorColorIndex(name: string): number {
+ let hash = 0;
+ for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
+ return Math.abs(hash) % AUTHOR_COLORS.length;
+}
+
function AuthorAvatar({ name }: { name: string }) {
const initials = name
.split(/[\s@._-]+/)
@@ -14,14 +33,7 @@ function AuthorAvatar({ name }: { name: string }) {
.map((p) => p[0]?.toUpperCase() ?? "")
.join("");
- // Deterministic color from name
- let hash = 0;
- for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
- const colors = [
- "bg-blue-500", "bg-purple-500", "bg-green-500", "bg-yellow-500",
- "bg-pink-500", "bg-indigo-500", "bg-teal-500", "bg-orange-500",
- ];
- const color = colors[Math.abs(hash) % colors.length];
+ const color = AUTHOR_COLORS[authorColorIndex(name)];
return (
<div
@@ -34,33 +46,127 @@ function AuthorAvatar({ name }: { name: string }) {
);
}
+function getVelocityLabel(git: GitMetadataResponse): { label: string; color: string } {
+ if (git.commit_count_90d === 0) return { label: "Inactive", color: "text-[var(--color-text-tertiary)]" };
+ const rate30 = git.commit_count_30d / 30;
+ const rate90 = git.commit_count_90d / 90;
+ if (rate30 > rate90 * 1.2) return { label: "Accelerating", color: "text-red-400" };
+ if (rate30 < rate90 * 0.8) return { label: "Cooling", color: "text-green-400" };
+ return { label: "Steady", color: "text-[var(--color-text-secondary)]" };
+}
+
export function GitHistoryPanel({ git }: GitHistoryPanelProps) {
const commits = git.significant_commits ?? [];
+ const velocity = getVelocityLabel(git);
return (
<div className="space-y-4">
- {/* Top authors */}
+ {/* File lifecycle */}
+ <div>
+ <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
+ File Status
+ </p>
+ <div className="space-y-1.5">
+ <div className="flex items-center gap-2">
+ {git.is_hotspot && <Badge variant="outdated">Hotspot</Badge>}
+ {git.is_stable && <Badge variant="fresh">Stable</Badge>}
+ {!git.is_hotspot && !git.is_stable && <Badge variant="default">Active</Badge>}
+ <span className={`text-xs ${velocity.color}`}>{velocity.label}</span>
+ </div>
+ <div className="grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
+ <span className="text-[var(--color-text-tertiary)]">Age</span>
+ <span className="text-[var(--color-text-secondary)] tabular-nums">
+ {formatAgeDays(git.age_days)}
+ </span>
+ <span className="text-[var(--color-text-tertiary)]">Commits (90d)</span>
+ <span className="text-[var(--color-text-secondary)] tabular-nums">
+ {git.commit_count_90d}
+ </span>
+ <span className="text-[var(--color-text-tertiary)]">Churn</span>
+ <span className="text-[var(--color-text-secondary)] tabular-nums">
+ {Math.round(git.churn_percentile)}%
+ </span>
+ {git.first_commit_at && (
+ <>
+ <span className="text-[var(--color-text-tertiary)]">First commit</span>
+ <span className="text-[var(--color-text-secondary)]">
+ {formatDate(git.first_commit_at)}
+ </span>
+ </>
+ )}
+ {git.last_commit_at && (
+ <>
+ <span className="text-[var(--color-text-tertiary)]">Last commit</span>
+ <span className="text-[var(--color-text-secondary)]">
+ {formatRelativeTime(git.last_commit_at)}
+ </span>
+ </>
+ )}
+ {git.bus_factor != null && (
+ <>
+ <span className="text-[var(--color-text-tertiary)]">Bus factor</span>
+ <span className={`tabular-nums ${git.bus_factor <= 1 ? "text-red-400" : "text-[var(--color-text-secondary)]"}`}>
+ {git.bus_factor}
+ </span>
+ </>
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Commit categories sparkline */}
+ {git.commit_categories && Object.keys(git.commit_categories).length > 0 && (
+ <div>
+ <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
+ Commit Types
+ </p>
+ <CommitCategorySparkline categories={git.commit_categories} />
+ </div>
+ )}
+
+ {/* Top authors with bars */}
{git.top_authors && git.top_authors.length > 0 && (
<div>
<p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
Authors
</p>
- <div className="space-y-1.5">
+ <div className="space-y-2">
{git.top_authors.slice(0, 4).map((author) => (
- <div key={author.email} className="flex items-center gap-2 text-xs">
- <AuthorAvatar name={author.name} />
- <span className="flex-1 truncate text-[var(--color-text-secondary)]">
- {author.name}
- </span>
- <span className="text-[var(--color-text-tertiary)] tabular-nums shrink-0">
- {Math.round(author.pct * 100)}%
- </span>
+ <div key={author.email} className="space-y-0.5">
+ <div className="flex items-center gap-2 text-xs">
+ <AuthorAvatar name={author.name} />
+ <span className="flex-1 truncate text-[var(--color-text-secondary)]">
+ {author.name}
+ </span>
+ <span className="text-[var(--color-text-tertiary)] tabular-nums shrink-0">
+ {Math.round(author.pct * 100)}%
+ </span>
+ </div>
+ <div className="h-1 w-full rounded-full bg-[var(--color-bg-elevated)] ml-7">
+ <div
+ className="h-1 rounded-full transition-all"
+ style={{
+ width: `${Math.min(100, author.pct * 100)}%`,
+ backgroundColor: AUTHOR_BAR_COLORS[authorColorIndex(author.name)],
+ }}
+ />
+ </div>
</div>
))}
</div>
</div>
)}
+ {/* Co-change partners */}
+ {git.co_change_partners && git.co_change_partners.length > 0 && (
+ <div>
+ <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider mb-2">
+ Co-change Partners
+ </p>
+ <CoChangeList partners={git.co_change_partners} />
+ </div>
+ )}
+
{/* Recent commits */}
{commits.length > 0 && (
<div>
@@ -75,14 +181,14 @@ export function GitHistoryPanel({ git }: GitHistoryPanelProps) {
<div className="w-px flex-1 bg-[var(--color-border-default)] mt-1" />
</div>
<div className="min-w-0 pb-2">
- <p className="text-xs text-[var(--color-text-secondary)] leading-snug line-clamp-2 break-words">
+ <p className="text-xs text-[var(--color-text-secondary)] leading-snug line-clamp-3 break-words" title={commit.message}>
{commit.message}
</p>
<div className="flex items-center gap-1.5 mt-0.5 flex-wrap">
<span className="font-mono text-[10px] text-[var(--color-accent-primary)]">
{commit.sha.slice(0, 7)}
</span>
- <span className="text-[10px] text-[var(--color-text-tertiary)] truncate max-w-[80px]">
+ <span className="text-[10px] text-[var(--color-text-tertiary)] truncate max-w-[120px]" title={commit.author}>
{commit.author}
</span>
<span className="text-[10px] text-[var(--color-text-tertiary)]">
@@ -96,7 +202,7 @@ export function GitHistoryPanel({ git }: GitHistoryPanelProps) {
</div>
)}
- {commits.length === 0 && (
+ {commits.length === 0 && (!git.top_authors || git.top_authors.length === 0) && (
<p className="text-xs text-[var(--color-text-tertiary)]">No commit history available.</p>
)}
</div>
diff --git a/packages/web/src/lib/api/types.ts b/packages/web/src/lib/api/types.ts
index 2f125b596..c4c90ce75 100644
--- a/packages/web/src/lib/api/types.ts
+++ b/packages/web/src/lib/api/types.ts
@@ -292,6 +292,8 @@ export interface GitMetadataResponse {
primary_owner_name: string | null;
primary_owner_email: string | null;
primary_owner_commit_pct: number | null;
+ recent_owner_name: string | null;
+ recent_owner_commit_pct: number | null;
top_authors: Array<{ name: string; email: string; commit_count: number; pct: number }>;
significant_commits: Array<{ sha: string; date: string; message: string; author: string }>;
co_change_partners: Array<{ file_path: string; co_change_count: number }>;
@@ -299,14 +301,29 @@ export interface GitMetadataResponse {
is_stable: boolean;
churn_percentile: number;
age_days: number;
+ bus_factor: number;
+ contributor_count: number;
+ lines_added_90d: number;
+ lines_deleted_90d: number;
+ avg_commit_size: number;
+ commit_categories: Record<string, number>;
+ merge_commit_count_90d: number;
}
export interface HotspotResponse {
file_path: string;
commit_count_90d: number;
+ commit_count_30d: number;
churn_percentile: number;
primary_owner: string | null;
is_hotspot: boolean;
+ is_stable: boolean;
+ bus_factor: number;
+ contributor_count: number;
+ lines_added_90d: number;
+ lines_deleted_90d: number;
+ avg_commit_size: number;
+ commit_categories: Record<string, number>;
}
export interface OwnershipEntry {
@@ -322,7 +339,7 @@ export interface GitSummaryResponse {
hotspot_count: number;
stable_count: number;
average_churn_percentile: number;
- top_owners: Array<{ name: string; email: string; file_count: number; pct: number }>;
+ top_owners: Array<{ name: string; email?: string; file_count: number; pct: number }>;
}
// ---------------------------------------------------------------------------
diff --git a/packages/web/src/lib/utils/format.ts b/packages/web/src/lib/utils/format.ts
index 75daa757e..cdd0e9291 100644
--- a/packages/web/src/lib/utils/format.ts
+++ b/packages/web/src/lib/utils/format.ts
@@ -75,14 +75,31 @@ export function formatLOC(n: number): string {
return String(n);
}
-/** Truncate a file path to fit in constrained UI: src/very/long/path/file.py → …/path/file.py */
-export function truncatePath(path: string, maxChars = 40): string {
+/** Truncate a file path keeping as many trailing components as fit: src/very/long/path/file.py → …/long/path/file.py */
+export function truncatePath(path: string, maxChars = 60): string {
if (path.length <= maxChars) return path;
const parts = path.split("/");
- if (parts.length <= 2) return `…${path.slice(-(maxChars - 1))}`;
- // Keep the filename + one parent
- const tail = parts.slice(-2).join("/");
- return `…/${tail}`;
+ if (parts.length <= 1) return `…${path.slice(-(maxChars - 1))}`;
+ // Progressively include more trailing path components until we exceed maxChars
+ for (let i = parts.length - 2; i >= 1; i--) {
+ const candidate = `…/${parts.slice(i).join("/")}`;
+ if (candidate.length <= maxChars) return candidate;
+ }
+ // Just filename
+ const filename = parts[parts.length - 1];
+ return filename.length <= maxChars ? `…/${filename}` : `…${filename.slice(-(maxChars - 1))}`;
+}
+
+/** Format age in days to human-readable: 45 → "1.5 months", 400 → "1.1 years" */
+export function formatAgeDays(n: number): string {
+ if (n < 1) return "< 1 day";
+ if (n < 30) return `${n} day${n !== 1 ? "s" : ""}`;
+ if (n < 365) {
+ const months = Math.round(n / 30 * 10) / 10;
+ return `${months} month${months !== 1 ? "s" : ""}`;
+ }
+ const years = Math.round(n / 365 * 10) / 10;
+ return `${years} year${years !== 1 ? "s" : ""}`;
}
/** Format a confidence score as a percentage string: 0.87 → "87%" */