mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-10 04:00:24 +00:00
update
This commit is contained in:
parent
ef17133235
commit
c7a2e7d376
2 changed files with 18 additions and 16 deletions
|
|
@ -832,15 +832,18 @@ export class FileReader {
|
|||
if (stats.isDirectory()) {
|
||||
const taskId = taskDir.replace('task_', '');
|
||||
const taskFiles = this.getFilesRecursive(taskPath, taskPath);
|
||||
|
||||
// Add task and project context to each file
|
||||
const enrichedFiles = taskFiles.map(file => ({
|
||||
...file,
|
||||
task_id: taskId,
|
||||
project_id: projectId,
|
||||
// Add relative path from project root
|
||||
relativePath: path.relative(projectPath, file.path)
|
||||
}));
|
||||
|
||||
const enrichedFiles = taskFiles.map(file => {
|
||||
const fileDir = path.dirname(file.path);
|
||||
const relativeParentPath = path.relative(projectPath, fileDir);
|
||||
|
||||
return {
|
||||
...file,
|
||||
task_id: taskId,
|
||||
project_id: projectId,
|
||||
relativePath: relativeParentPath === '.' ? '' : relativeParentPath
|
||||
};
|
||||
});
|
||||
|
||||
allFiles.push(...enrichedFiles);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,6 @@ export default function Folder({ data }: { data?: Agent }) {
|
|||
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
|
||||
// Build tree structure from flat file list
|
||||
const buildFileTree = (files: FileInfo[]): FileTreeNode => {
|
||||
const root: FileTreeNode = {
|
||||
name: "root",
|
||||
|
|
@ -216,17 +215,20 @@ export default function Folder({ data }: { data?: Agent }) {
|
|||
isFolder: true,
|
||||
};
|
||||
|
||||
// Create a map for quick access
|
||||
const nodeMap = new Map<string, FileTreeNode>();
|
||||
nodeMap.set("", root);
|
||||
|
||||
// Sort files so folders come before files and by path depth
|
||||
const sortedFiles = [...files].sort((a, b) => {
|
||||
const depthA = (a.relativePath || "").split("/").filter(Boolean).length;
|
||||
const depthB = (b.relativePath || "").split("/").filter(Boolean).length;
|
||||
return depthA - depthB;
|
||||
});
|
||||
|
||||
for (const file of sortedFiles) {
|
||||
const fullRelativePath = file.relativePath
|
||||
? `${file.relativePath}/${file.name}`
|
||||
: file.name;
|
||||
|
||||
const parentPath = file.relativePath || "";
|
||||
const parentNode = nodeMap.get(parentPath) || root;
|
||||
|
||||
|
|
@ -243,10 +245,7 @@ export default function Folder({ data }: { data?: Agent }) {
|
|||
parentNode.children!.push(node);
|
||||
|
||||
if (file.isFolder) {
|
||||
const folderPath = parentPath
|
||||
? `${parentPath}/${file.name}`
|
||||
: file.name;
|
||||
nodeMap.set(folderPath, node);
|
||||
nodeMap.set(fullRelativePath, node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue