import React, { useMemo, useState } from 'react'; import { ChevronRight, FileCode } from 'lucide-react'; import { FilePath } from '../ui/FilePath'; interface FileTreeProps { structure: Record; onFileSelect?: (filePath: string) => void; } /** * Workspace navigator. * * A quiet left rail rather than a bordered card: a mono section label, thin * guide lines for depth, and a clear selected state. Behaviour is unchanged — * folders toggle, files call `onFileSelect` with the same full path as before. */ export const FileTree: React.FC = ({ structure, onFileSelect }) => { const [openFolders, setOpenFolders] = useState>({ root: true, src: true, }); const [selectedFile, setSelectedFile] = useState(null); const toggleFolder = (folder: string) => { setOpenFolders((prev) => ({ ...prev, [folder]: !prev[folder] })); }; const handleFileClick = (path: string) => { setSelectedFile(path); onFileSelect?.(path); }; const directories = useMemo( () => Object.keys(structure).sort((a, b) => { if (a === 'root' || a === '.') return -1; if (b === 'root' || b === '.') return 1; return a.localeCompare(b); }), [structure] ); const fileCount = useMemo( () => Object.values(structure).reduce((sum, files) => sum + files.length, 0), [structure] ); return ( ); }; export default FileTree;