Roo-Code/test-small-case.js
Roo Code aa77ada1f9 Fix #5301: Prevent early termination in list-files when directory has many files
- Remove early process termination in execRipgrep that was causing incomplete directory traversal
- Implement balanced sampling algorithm to ensure fair representation across all directories
- Increase timeout values to allow complete directory scanning before applying limits
- Add applyBalancedSampling function to distribute file selection evenly across directories
- Maintain existing 200-file limit while ensuring all directories are represented

This fixes the issue where having 200+ files in one directory (e.g., 'a/') would cause
other directories (e.g., 'b/') to be completely ignored in the file listing results.
2025-07-01 15:59:57 +00:00

30 lines
1 KiB
JavaScript

const fs = require("fs")
const path = require("path")
// Create a smaller test case to verify the fix
const testDir = "./test-small-case"
// Clean up if exists
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true })
}
// Create the test structure
fs.mkdirSync(testDir)
fs.mkdirSync(path.join(testDir, "a"))
fs.mkdirSync(path.join(testDir, "b"))
// Create 10 files in folder 'a'
for (let i = 1; i <= 10; i++) {
fs.writeFileSync(path.join(testDir, "a", `file${i.toString().padStart(2, "0")}.txt`), `Content of file ${i}`)
}
// Create 3 files in folder 'b'
fs.writeFileSync(path.join(testDir, "b", "important-file1.txt"), "Important content 1")
fs.writeFileSync(path.join(testDir, "b", "important-file2.txt"), "Important content 2")
fs.writeFileSync(path.join(testDir, "b", "important-file3.txt"), "Important content 3")
console.log("Small test directory structure created:")
console.log(`- ${testDir}/a/ contains 10 files`)
console.log(`- ${testDir}/b/ contains 3 files`)
console.log("Total: 13 files + 2 directories")