Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 18, 2025

Related GitHub Issue

Closes: #10169

Description

This PR attempts to address Issue #10169 by filtering the @ mention file picker results using the existing RooIgnoreController.

Key implementation details:

  • Modified the searchFiles case in webviewMessageHandler.ts to filter results using RooIgnoreController
  • Uses the existing RooIgnoreController from the current task if available, otherwise creates a temporary one for the workspace
  • Respects the existing showRooIgnoredFiles setting to allow users to toggle this behavior
  • No webview changes needed since filtering happens server-side before results reach the frontend

Files changed:

  • src/core/webview/webviewMessageHandler.ts: Added filtering logic to the searchFiles case
  • src/core/webview/__tests__/webviewMessageHandler.searchFiles.spec.ts: Added comprehensive test coverage

Test Procedure

  1. Create a .rooignore file in your workspace with some patterns (e.g., secrets/, *.env)
  2. Create files/folders matching those patterns
  3. Open Roo Code and type @ in the chat input
  4. Search for files - the ignored files/folders should NOT appear in the results
  5. Toggle showRooIgnoredFiles setting to true and verify ignored files now appear

Automated tests:

cd src && npx vitest run core/webview/__tests__/webviewMessageHandler.searchFiles.spec.ts

Tests cover:

  • Filtering results when showRooIgnoredFiles is false
  • Not filtering results when showRooIgnoredFiles is true
  • Using existing RooIgnoreController from current task
  • Creating temporary controller when no task exists
  • Error handling scenarios

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on the linked issue
  • Self-Review: I have performed a thorough self-review of my code
  • Testing: New tests have been added to cover the changes
  • Documentation Impact: No documentation updates required
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines

Documentation Updates

  • No documentation updates are required.

Additional Notes

This implementation is consistent with how .rooignore works for other file operations in Roo Code. The filtering happens in the backend handler, so the webview naturally receives fewer (filtered) results without any UI changes needed.

Feedback and guidance are welcome!

- Modify searchFiles case in webviewMessageHandler.ts to filter results using RooIgnoreController
- Use existing RooIgnoreController from current task if available, otherwise create a temporary one
- Respect showRooIgnoredFiles setting to allow users to toggle this behavior
- Add comprehensive test coverage for the new filtering behavior

Fixes #10169
@roomote
Copy link
Contributor Author

roomote bot commented Dec 18, 2025

Rooviewer Clock   See task on Roo Cloud

Reviewed this PR. Found 1 issue that should be addressed before merging.

  • Resource leak in temporary RooIgnoreController - The temporary controller created when no task exists is never disposed, causing file watchers to accumulate.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 18, 2025
Comment on lines +1696 to +1714
// Get the RooIgnoreController from the current task, or create a new one
const currentTask = provider.getCurrentTask()
let rooIgnoreController = currentTask?.rooIgnoreController

// If no current task or no controller, create a temporary one
if (!rooIgnoreController) {
rooIgnoreController = new RooIgnoreController(workspacePath)
await rooIgnoreController.initialize()
}

// Get showRooIgnoredFiles setting from state
const { showRooIgnoredFiles = false } = (await provider.getState()) ?? {}

// Filter results using RooIgnoreController if showRooIgnoredFiles is false
let filteredResults = results
if (!showRooIgnoredFiles && rooIgnoreController) {
const allowedPaths = rooIgnoreController.filterPaths(results.map((r) => r.path))
filteredResults = results.filter((r) => allowedPaths.includes(r.path))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resource leak: When a temporary RooIgnoreController is created here, it is never disposed. The constructor calls setupFileWatcher() which creates a vscode.workspace.createFileSystemWatcher() and adds it to the controller's disposables array. Without calling dispose(), these file watchers accumulate and leak resources each time searchFiles is called without an active task.

Suggested change
// Get the RooIgnoreController from the current task, or create a new one
const currentTask = provider.getCurrentTask()
let rooIgnoreController = currentTask?.rooIgnoreController
// If no current task or no controller, create a temporary one
if (!rooIgnoreController) {
rooIgnoreController = new RooIgnoreController(workspacePath)
await rooIgnoreController.initialize()
}
// Get showRooIgnoredFiles setting from state
const { showRooIgnoredFiles = false } = (await provider.getState()) ?? {}
// Filter results using RooIgnoreController if showRooIgnoredFiles is false
let filteredResults = results
if (!showRooIgnoredFiles && rooIgnoreController) {
const allowedPaths = rooIgnoreController.filterPaths(results.map((r) => r.path))
filteredResults = results.filter((r) => allowedPaths.includes(r.path))
}
// Get the RooIgnoreController from the current task, or create a new one
const currentTask = provider.getCurrentTask()
let rooIgnoreController = currentTask?.rooIgnoreController
let isTemporaryController = false
// If no current task or no controller, create a temporary one
if (!rooIgnoreController) {
rooIgnoreController = new RooIgnoreController(workspacePath)
await rooIgnoreController.initialize()
isTemporaryController = true
}
// Get showRooIgnoredFiles setting from state
const { showRooIgnoredFiles = false } = (await provider.getState()) ?? {}
// Filter results using RooIgnoreController if showRooIgnoredFiles is false
let filteredResults = results
if (!showRooIgnoredFiles && rooIgnoreController) {
const allowedPaths = rooIgnoreController.filterPaths(results.map((r) => r.path))
filteredResults = results.filter((r) => allowedPaths.includes(r.path))
}
// Dispose temporary controller to clean up file watchers
if (isTemporaryController && rooIgnoreController) {
rooIgnoreController.dispose()
}

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] .rooignore should be used to filter files and folders when using @ to add context

4 participants