Skip to content

feat: add respectGitIgnore setting to control .gitignore filtering#11250

Draft
roomote[bot] wants to merge 2 commits intomainfrom
feature/respect-gitignore-setting
Draft

feat: add respectGitIgnore setting to control .gitignore filtering#11250
roomote[bot] wants to merge 2 commits intomainfrom
feature/respect-gitignore-setting

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 6, 2026

This PR attempts to address Issue #11249, specifically the follow-up comment by @emeraldcheshire asking whether the setting should apply beyond just the indexer.

Summary

Adds a new codebaseIndexRespectGitIgnore setting (default: true) that controls whether .gitignore patterns are respected when listing files. The setting affects all file-listing functionality in Roo Code, not just the indexer:

  1. Code Indexer scanner - original issue scope
  2. list_files tool - when the AI requests a directory listing during tasks
  3. Environment details - workspace file listing shown in context
  4. WorkspaceTracker - file path tracking for the workspace

When disabled (false), only .rooignore is used for filtering, allowing gitignored files (e.g., external API headers) to be discovered and indexed.

Changes

  • packages/types: Add codebaseIndexRespectGitIgnore to the codebase index config schema and types
  • src/services/glob/list-files.ts: Add optional respectGitIgnore parameter
    • Passes --no-ignore-vcs to ripgrep when false
    • Skips loading .gitignore patterns in createIgnoreInstance when false
  • src/services/code-index: Thread setting through manager, factory, and scanner
  • src/core: Thread setting through ListFilesTool and getEnvironmentDetails
  • src/integrations/workspace: Thread setting through WorkspaceTracker
  • webview-ui: Add toggle in CodeIndexPopover advanced settings
  • i18n: Add English translations for the new setting

Testing

All existing tests pass (45 tests across 5 test files). Updated the WorkspaceTracker test to account for the new parameter.

Feedback and guidance are welcome.


Important

Introduces respectGitIgnore setting to control .gitignore filtering across file-listing functionalities, with UI integration and configuration updates.

  • Behavior:
    • Adds respectGitIgnore setting to control .gitignore filtering across all file-listing functionalities.
    • Default is true, meaning .gitignore is respected; when false, only .rooignore is used.
  • Configuration:
    • Updates codebaseIndexConfigSchema in codebase-index.ts to include respectGitIgnore.
    • Threads respectGitIgnore through config-manager.ts, manager.ts, and service-factory.ts.
  • Services:
    • Modifies listFiles() in list-files.ts to accept respectGitIgnore parameter.
    • Updates DirectoryScanner in scanner.ts to use respectGitIgnore.
    • Adjusts WorkspaceTracker in WorkspaceTracker.ts to consider respectGitIgnore.
  • UI:
    • Adds toggle for respectGitIgnore in CodeIndexPopover.tsx.
    • Updates i18n strings in settings.json for the new setting.

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

…ross all file listing

Adds a new `codebaseIndexRespectGitIgnore` setting (default: true) that controls
whether .gitignore patterns are respected when listing files. This affects:

- Code indexer scanner (original issue scope)
- list_files tool (AI task file listings)
- Environment details (workspace file context)
- WorkspaceTracker (workspace file tracking)

When disabled (false), only .rooignore is used for filtering, allowing
gitignored files (e.g. external API headers) to be discovered and indexed.

Changes:
- packages/types: Add codebaseIndexRespectGitIgnore to schema and types
- src/services/glob/list-files.ts: Add respectGitIgnore parameter
  - Pass --no-ignore-vcs to ripgrep when false
  - Skip gitignore patterns in createIgnoreInstance when false
- src/services/code-index: Thread setting through manager, factory, scanner
- src/core: Thread setting through ListFilesTool, getEnvironmentDetails
- src/integrations/workspace: Thread setting through WorkspaceTracker
- webview-ui: Add toggle in CodeIndexPopover advanced settings
- i18n: Add English translations for new setting

Closes #11249
@roomote
Copy link
Contributor Author

roomote bot commented Feb 6, 2026

Rooviewer Clock   See task

Re-reviewed after 7973a57. Both previously flagged issues are resolved. No new issues found.

  • Bug: Toggling codebaseIndexRespectGitIgnore does not trigger a code index service restart because doesConfigChangeRequireRestart in config-manager.ts does not track this setting. The scanner keeps the stale value until an unrelated config change forces recreation.
  • Nit: respectGitIgnore parameter is passed to buildRecursiveArgs and buildNonRecursiveArgs but never used in either function body (dead code).
Previous reviews

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

Comment on lines 316 to 322
let respectGitIgnore = true
try {
const content = await fs.readFile(ignorePath, "utf8")
ignoreInstance.add(content)
ignoreInstance.add(".gitignore")
} catch (error) {
// Should never happen: reading file failed even though it exists
console.error("Unexpected error loading .gitignore:", error)
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, {
error: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined,
location: "_recreateServices",
})
const codebaseIndexConfig = this._configManager!.getContextProxy()?.getGlobalState("codebaseIndexConfig")
respectGitIgnore = codebaseIndexConfig?.codebaseIndexRespectGitIgnore ?? true
} catch {
// Fall back to default (respect .gitignore) if config proxy is not available
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Toggling codebaseIndexRespectGitIgnore won't actually cause the code index to re-scan with the new value. doesConfigChangeRequireRestart in config-manager.ts does not compare previous vs. current respectGitIgnore, so handleSettingsChange() will see requiresRestart: false and skip service recreation. The scanner retains the stale value until something else (e.g., a provider change) forces a restart. The fix is to track respectGitIgnore in PreviousConfigSnapshot, populate it in loadConfiguration, and compare it in doesConfigChangeRequireRestart.

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

* Build ripgrep arguments for recursive directory traversal
*/
function buildRecursiveArgs(dirPath: string): string[] {
function buildRecursiveArgs(dirPath: string, respectGitIgnore: boolean = true): string[] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: respectGitIgnore is accepted as a parameter here but never referenced in the function body (same for buildNonRecursiveArgs). The actual --no-ignore-vcs flag is correctly added in buildRipgrepArgs, so these parameters are dead code. Consider removing them to avoid confusing future readers into thinking these functions contain gitignore-related branching logic.

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

@emeraldcheshire
Copy link

@roomote
Given the expanded scope beyond the indexer, should the setting name be generalized as well?

Should the setting visible to users be simply "Respect .gitignore"? (In the config schema, simply respectGitIgnore.)

@roomote
Copy link
Contributor Author

roomote bot commented Feb 6, 2026

Fixaroo Clock   See task · See live changes

Renamed codebaseIndexRespectGitIgnore to respectGitIgnore across the schema, types, backend consumers, and UI. Also fixed the restart-tracking bug by adding respectGitIgnore to PreviousConfigSnapshot and doesConfigChangeRequireRestart, and removed unused respectGitIgnore params from buildRecursiveArgs/buildNonRecursiveArgs. All local checks passed.

View commit | Revert commit

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants