Skip to content

Commit 5bb82d7

Browse files
committed
fix: file type detection for json/yaml/markdown, reset collapse state on file change
1 parent 081c314 commit 5bb82d7

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

frontend/src/components/DependencyGraph/GraphNode.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ const RISK_CONFIG: Record<RiskLevel, { variant: 'default' | 'secondary' | 'destr
6969

7070
function getFileType(path: string, language: string): string {
7171
const fileName = path.split('/').pop() || ''
72-
73-
if (fileName.includes('.test.') || fileName.includes('_test.') || fileName.includes('.spec.')) {
72+
const lower = fileName.toLowerCase()
73+
const ext = lower.split('.').pop() || ''
74+
75+
if (lower.includes('.test.') || lower.includes('_test.') || lower.includes('.spec.')) {
7476
return 'test'
7577
}
76-
if (fileName.includes('config') || fileName.endsWith('.json') || fileName.endsWith('.yaml') || fileName.endsWith('.yml')) {
77-
return 'config'
78-
}
79-
if (['python', 'javascript', 'typescript'].includes(language)) {
80-
return language
81-
}
78+
if (ext === 'json') return 'json'
79+
if (ext === 'yaml' || ext === 'yml') return 'yaml'
80+
if (ext === 'md' || ext === 'markdown') return 'markdown'
81+
if (lower.includes('config')) return 'config'
82+
if (['python', 'javascript', 'typescript'].includes(language)) return language
8283
return 'unknown'
8384
}
8485

frontend/src/components/DependencyGraph/ImpactPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo, useState } from 'react'
1+
import { memo, useState, useEffect } from 'react'
22
import {
33
X,
44
ChevronDown,
@@ -115,6 +115,11 @@ function CollapsibleSection({
115115
}) {
116116
const [isOpen, setIsOpen] = useState(defaultOpen)
117117

118+
// Reset collapse state when file selection changes
119+
useEffect(() => {
120+
setIsOpen(defaultOpen)
121+
}, [defaultOpen, files])
122+
118123
const variantStyles = {
119124
direct: 'text-rose-600 dark:text-rose-400',
120125
transitive: 'text-amber-600 dark:text-amber-400',

0 commit comments

Comments
 (0)