-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: filter @ mention file search results using .rooignore #10174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- 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
Reviewed this PR. Found 1 issue that should be addressed before merging.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // 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)) | ||
| } |
There was a problem hiding this comment.
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.
| // 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.
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:
searchFilescase inwebviewMessageHandler.tsto filter results usingRooIgnoreControllerRooIgnoreControllerfrom the current task if available, otherwise creates a temporary one for the workspaceshowRooIgnoredFilessetting to allow users to toggle this behaviorFiles changed:
src/core/webview/webviewMessageHandler.ts: Added filtering logic to thesearchFilescasesrc/core/webview/__tests__/webviewMessageHandler.searchFiles.spec.ts: Added comprehensive test coverageTest Procedure
.rooignorefile in your workspace with some patterns (e.g.,secrets/,*.env)@in the chat inputshowRooIgnoredFilessetting to true and verify ignored files now appearAutomated tests:
Tests cover:
showRooIgnoredFilesis falseshowRooIgnoredFilesis trueRooIgnoreControllerfrom current taskPre-Submission Checklist
Documentation Updates
Additional Notes
This implementation is consistent with how
.rooignoreworks 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!