Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 1, 2025

Summary

This PR fixes an issue where the listFilesRecursive tool was unable to retrieve any files when the project was located under a /tmp directory path.

Problem

The previous implementation used the ripgrep exclusion pattern !**/${dir}/** which excluded any path containing the directory name anywhere in the path. This meant that if your project was under /tmp/project, all files would be excluded because "tmp" appeared in the parent path.

Solution

Changed the exclusion patterns from !**/${dir}/** to !**/${dir}/ to only exclude directories with the specified name at any level, not paths containing the name. This ensures that:

  • Projects under /tmp can have their files listed correctly
  • Nested directories named "tmp" or "temp" within projects are still properly excluded
  • The behavior remains consistent for both recursive and non-recursive listing

Changes

  1. Modified src/services/glob/list-files.ts:

    • Updated buildRecursiveArgs() to use !**/${dir}/ pattern
    • Updated buildNonRecursiveArgs() to use !${dir}/ pattern
  2. Added comprehensive test coverage in src/services/glob/__tests__/list-files-tmp-directory.spec.ts:

    • Test for listing files in a project under /tmp directory
    • Test for excluding nested tmp directories within a project under /tmp

Testing

  • All existing tests pass ✅
  • New tests specifically verify the fix works correctly ✅
  • Manual testing confirms files under /tmp/project are now properly listed

Fixes #6545


Important

Fixes listFilesRecursive to correctly list files in projects under /tmp by updating exclusion patterns and adds tests for verification.

  • Behavior:
    • Fixes listFilesRecursive to correctly list files in projects under /tmp by changing exclusion pattern from !**/${dir}/** to !**/${dir}/ in list-files.ts.
    • Ensures nested directories named "tmp" or "temp" are still excluded.
  • Testing:
    • Adds list-files-tmp-directory.spec.ts with tests for projects under /tmp and nested tmp directories.
    • Confirms files under /tmp/project are listed correctly and nested tmp directories are excluded.
  • Misc:
    • Updates buildRecursiveArgs() and buildNonRecursiveArgs() in list-files.ts to reflect new exclusion pattern.

This description was created by Ellipsis for 60fbd5d. You can customize this summary. It will automatically update as commits are pushed.

…rectory

- Changed ripgrep exclusion patterns from !**/${dir}/** to !**/${dir}/ to only exclude directories with the specified name, not paths containing the name
- This fixes the issue where projects under /tmp were having all their files excluded because "tmp" appeared in the parent path
- Added comprehensive test cases to verify the fix works correctly
- Ensures that nested tmp directories are still properly excluded while allowing projects under /tmp to work

Fixes #6545
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 1, 2025 09:56
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 1, 2025
@dosubot dosubot bot added the bug Something isn't working label Aug 1, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in production - technically possible but morally questionable. I've reviewed the changes and left some suggestions inline.

// For all other cases, exclude directories with this name at any level
// Use !**/${dir}/ to match directories only (with trailing slash)
// This prevents excluding files when the parent path contains the directory name
args.push("-g", `!**/${dir}/`)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern relies on ripgrep matching directories with trailing slashes. While this works correctly, could we add a comment explaining this dependency to help future maintainers understand why the trailing slash is crucial here?

args.push("-g", `!**/${dir}/**`)
// For all other cases, exclude directories with this name at any level
// Use !**/${dir}/ to match directories only (with trailing slash)
// This prevents excluding files when the parent path contains the directory name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider expanding this comment to explicitly mention that this change fixes the issue where projects under /tmp were being excluded. Something like:

vi.restoreAllMocks()
})

it("should list files in a project under /tmp directory", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test coverage for the main issue! Consider adding a few more edge case tests:

  • Projects with "tmp" in their name (e.g., )
  • Multiple nested tmp directories (e.g., )
  • Mixed case directories (e.g., "Tmp", "TEMP")

These would help ensure the fix is robust across different scenarios.

"-g",
"!**/vendor/",
"-g",
"!**/tmp/", // This should exclude tmp directories, but not the parent /tmp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could be clearer. Consider:

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 1, 2025
@NaccOll
Copy link
Contributor

NaccOll commented Aug 1, 2025

@roomote-agent

Please make the modifications in this PR, do not open a new PR.

The DIRS_TO_IGNORE should take effect on the target directory and its subdirectories. It should not prevent listFilesRecursive from searching any files just because the target directory contains part of DIRS_TO_IGNORE.

@roomote
Copy link
Contributor Author

roomote bot commented Aug 1, 2025

Hi @NaccOll, I understand your request. You want to ensure that DIRS_TO_IGNORE only excludes directories within the target directory and its subdirectories, not prevent searching when the target directory path contains part of DIRS_TO_IGNORE (like when a project is under /tmp).

I'll review the current implementation and make the necessary modifications to ensure this behavior is correctly implemented. Working on it now!

@roomote
Copy link
Contributor Author

roomote bot commented Aug 1, 2025

Hi @NaccOll,

I've reviewed the implementation and I'm happy to confirm that the current fix already addresses your concern correctly! Here's how it works:

How the Fix Works

The key changes in this PR:

  1. Changed the exclusion pattern from !**/${dir}/** to !**/${dir}/ for recursive searches
  2. Changed from !${dir} and !${dir}/** to just !${dir}/ for non-recursive searches

Why This Addresses Your Concern

When listFilesRecursive is called with a path like /tmp/project:

  • Ripgrep is executed with /tmp/project as the search directory
  • The exclusion patterns (e.g., !**/tmp/) are applied relative to the search directory
  • This means !**/tmp/ will only exclude subdirectories named "tmp" within /tmp/project, not the parent /tmp directory itself

Verification

I've verified this by:

  1. Running the existing tests which specifically test this scenario - all pass ✅
  2. The test "should list files in a project under /tmp directory" confirms files are correctly listed when the project is under /tmp
  3. The test "should exclude nested tmp directories within a project under /tmp" confirms that nested tmp directories within the project are still properly excluded

The implementation correctly ensures that DIRS_TO_IGNORE only affects subdirectories within the target directory, not the parent path. No additional changes are needed.

The fix is working as intended! 🎉

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 2, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 2, 2025
@NaccOll
Copy link
Contributor

NaccOll commented Aug 5, 2025

@roomote-agent close this pr

@roomote
Copy link
Contributor Author

roomote bot commented Aug 5, 2025

Acknowledged. I will close this PR as requested by @NaccOll.

@roomote roomote bot closed this Aug 5, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Aug 5, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 5, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Aug 5, 2025

PR #6546 has been successfully closed as requested. The pull request that fixed the listFilesRecursive issue for projects under /tmp directory is now closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

The listFilesRecursive tool is unable to retrieve any files under /tmp/project.

4 participants