Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jun 14, 2025

Summary

This PR fixes issue #4647 where .rooignore patterns for hidden directories (like .next) in nested projects were not being respected during codebase indexing.

Problem

The root cause was that list-files.ts had a blanket .* exclusion for hidden directories at the ripgrep level, which prevented .rooignore from ever seeing those paths. This meant that even if you added .next to .rooignore, it wouldn't work for codebase indexing because the files were already filtered out before .rooignore could process them.

Solution

Instead of modifying list-files.ts (which would have broader implications), this PR aligns the codebase indexing behavior with list-files.ts by:

  1. Extracting shared constants: Created DIRS_TO_IGNORE constant that includes the .* pattern
  2. Creating a helper function: isPathInIgnoredDirectory that checks if a path is in an ignored directory
  3. Updating processors: Both scanner.ts and file-watcher.ts now use this shared filtering logic
  4. Adding comprehensive tests: Added tests for both scanner and file-watcher to ensure hidden directories are properly filtered

Changes

  • Created src/services/glob/constants.ts with shared DIRS_TO_IGNORE constant
  • Created src/services/glob/ignore-utils.ts with isPathInIgnoredDirectory helper
  • Updated list-files.ts to use the shared constant
  • Updated scanner.ts to filter out hidden directories after getting file list
  • Updated file-watcher.ts to filter out hidden directories in file events
  • Added test cases in scanner.spec.ts for hidden directory filtering
  • Created comprehensive test suite file-watcher.spec.ts for file watcher filtering

Testing

All tests pass and the linting/type checking is clean. The new tests verify that:

  • Files in hidden directories (.git, .hidden, .next, etc.) are not processed during scanning
  • File watcher events for hidden directories are ignored
  • Nested hidden directories are handled correctly

Impact

This change ensures that codebase indexing respects the same directory exclusions as list-files.ts, providing consistent behavior across the extension. The performance impact is minimal as the filtering only involves string operations.

Fixes #4647


Important

Fixes hidden directory exclusion issue in indexing by aligning list-files.ts with .rooignore using shared constants and helper functions.

  • Behavior:
    • Fixes issue with .rooignore not respecting hidden directories during indexing.
    • Introduces isPathInIgnoredDirectory to check if a path is in an ignored directory.
    • Updates scanner.ts and file-watcher.ts to use shared filtering logic.
  • Constants and Helpers:
    • Creates DIRS_TO_IGNORE in constants.ts for shared directory exclusion patterns.
    • Adds isPathInIgnoredDirectory in ignore-utils.ts for path checking.
  • Tests:
    • Adds file-watcher.spec.ts to test file watcher behavior with hidden directories.
    • Updates scanner.spec.ts to test directory scanning with hidden directories.
  • Misc:
    • Updates list-files.ts to use DIRS_TO_IGNORE for consistent directory filtering.

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

…ng (#4647)

- Extract shared DIRS_TO_IGNORE constant including '.*' pattern
- Create isPathInIgnoredDirectory helper for consistent filtering
- Update scanner and file-watcher to use shared filtering logic
- Add comprehensive tests for hidden directory filtering
- Ensures codebase indexing respects the same exclusions as list-files

This fixes the issue where .rooignore patterns for hidden directories
(like .next) were not being respected during codebase indexing because
the ripgrep-level exclusion in list-files prevented .rooignore from
ever seeing those paths.
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners June 14, 2025 23:42
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jun 14, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 14, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jun 15, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 15, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 15, 2025
@mrubens mrubens merged commit 2e2f83b into main Jun 15, 2025
25 checks passed
@mrubens mrubens deleted the fix/4647-codebase-indexing-hidden-folders branch June 15, 2025 19:43
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 15, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs 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.

Roo indexes .next folder despite .rooignore file

4 participants