Skip to content

Commit 1cbf10a

Browse files
committed
fix(overview): compute critical files from edge data
Bug: High-Impact Files section was empty Cause: Relying on deps.metrics.most_critical_files from backend but Entry Points (which worked) computed from edges directly Fix: Compute critical files locally from same edge data - Sort by in-degree (most dependents first) - Consistent with Entry Points calculation - No backend dependency for this data
1 parent c195280 commit 1cbf10a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

frontend/src/components/CodebaseIntelligence.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ export function CodebaseIntelligence({ repo, apiKey, onTabChange }: CodebaseInte
3434
const intelligence = useMemo(() => {
3535
if (!deps?.metrics) return null
3636

37-
const criticalFiles = deps.metrics.most_critical_files || []
38-
const complexFiles = deps.metrics.most_complex_files || []
3937
const nodes = deps.nodes || []
4038
const edges = deps.edges || []
4139

42-
// Find entry points (high in-degree, low out-degree = API surface)
40+
// Calculate in-degree and out-degree from edges
4341
const inDegree: Record<string, number> = {}
4442
const outDegree: Record<string, number> = {}
4543

@@ -48,7 +46,13 @@ export function CodebaseIntelligence({ repo, apiKey, onTabChange }: CodebaseInte
4846
outDegree[e.source] = (outDegree[e.source] || 0) + 1
4947
})
5048

51-
// Entry points: imported by many, imports few
49+
// Critical files: highest in-degree (most dependents)
50+
const criticalFiles = Object.entries(inDegree)
51+
.map(([file, dependents]) => ({ file, dependents }))
52+
.sort((a, b) => b.dependents - a.dependents)
53+
.slice(0, 5)
54+
55+
// Entry points: imported by many, imports few (high in-degree, low out-degree)
5256
const entryPoints = nodes
5357
.map((n: any) => ({
5458
file: n.id,

0 commit comments

Comments
 (0)