MCPcopy Create free account
hub / github.com/modelscope/ms-agent / FileTreeView

Function FileTreeView

webui/frontend/src/components/ConversationView.tsx:2072–2167  ·  view source on GitHub ↗
({
  tree, path, expandedFolders, toggleFolder, selectedFile, onSelectFile, depth = 0
})

Source from the content-addressed store, hash-verified

2070}
2071
2072const FileTreeView: React.FC<FileTreeViewProps> = ({
2073 tree, path, expandedFolders, toggleFolder, selectedFile, onSelectFile, depth = 0
2074}) => {
2075 const theme = useTheme();
2076 const stripProgrammerPrefix = (name: string) => {
2077 if (!name.startsWith('programmer-')) return name;
2078 const stripped = name.slice('programmer-'.length);
2079 return stripped.length > 0 ? stripped : name;
2080 };
2081 const hasContent = Object.keys(tree.folders).length > 0 || tree.files.length > 0;
2082
2083 if (!hasContent && depth === 0) {
2084 return (
2085 <Box sx={{ p: 3, textAlign: 'center' }}>
2086 <Typography color="text.secondary">No files yet</Typography>
2087 </Box>
2088 );
2089 }
2090
2091 return (
2092 <>
2093 {/* Folders */}
2094 {Object.entries(tree.folders).map(([folderName, subtree]) => {
2095 const folderPath = path ? `${path}/${folderName}` : folderName;
2096 const isExpanded = expandedFolders.has(folderPath);
2097
2098 return (
2099 <Box key={folderPath}>
2100 <Box
2101 onClick={() => toggleFolder(folderPath)}
2102 sx={{
2103 py: 0.5,
2104 pl: depth * 2 + 1,
2105 pr: 1,
2106 cursor: 'pointer',
2107 display: 'flex',
2108 alignItems: 'center',
2109 gap: 0.5,
2110 '&:hover': { backgroundColor: alpha(theme.palette.primary.main, 0.05) },
2111 }}
2112 >
2113 {isExpanded ? (
2114 <ExpandMoreIcon sx={{ fontSize: 18, color: 'text.secondary' }} />
2115 ) : (
2116 <ChevronRightIcon sx={{ fontSize: 18, color: 'text.secondary' }} />
2117 )}
2118 {isExpanded ? (
2119 <FolderOpenIcon sx={{ fontSize: 18 }} color="warning" />
2120 ) : (
2121 <FolderIcon sx={{ fontSize: 18 }} color="warning" />
2122 )}
2123 <Typography variant="body2" sx={{ fontSize: '0.85rem' }}>
2124 {folderName}
2125 </Typography>
2126 </Box>
2127 {isExpanded && (
2128 <FileTreeView
2129 tree={subtree as TreeNode}

Callers

nothing calls this directly

Calls 2

toggleFolderFunction · 0.85
stripProgrammerPrefixFunction · 0.85

Tested by

no test coverage detected