feat: add option to pause file-watching after initial indexing #10448
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #8131
Description
This PR attempts to address Issue #8131, specifically the concern raised by @Jerrill about CPU-expensive file-watching operations when using multiple VSCode instances with git worktrees.
Key implementation details:
New workspace-scoped setting: Added
roo-cline.codeIndex.fileWatchingEnabled(default:true) with"scope": "resource"so each workspace/worktree can have independent settings.New IndexedPaused state: Added to the indexing state machine to distinguish between "Indexed with active watcher" and "Indexed without watcher".
Conditional watcher start: Modified the orchestrator to check
isFileWatchingEnabledafter initial indexing completes. If disabled, the state transitions toIndexedPausedinstead of starting the file watcher.Worktree support: Since each worktree is opened as a separate workspace in VSCode, and CodeIndexManager uses workspace-path-based singletons, each worktree gets its own independent CodeIndexManager instance with its own settings.
Usage for users with multiple worktrees:
roo-cline.codeIndex.fileWatchingEnabled: falsein worktrees where you want to reduce CPU usagecodebase_searchtool will still work using the existing indexTest Procedure
Unit tests: Added comprehensive tests in
src/services/code-index/__tests__/file-watching-pause.spec.tscovering:Run tests:
cd src && npx vitest run services/code-index/__tests__/file-watching-pause.spec.tsManual testing: Open workspace settings and toggle
roo-cline.codeIndex.fileWatchingEnabled, then trigger indexing to observe state changes.Pre-Submission Checklist
Screenshots / Videos
N/A - This is a backend feature with no UI changes.
Documentation Updates
roo-cline.codeIndex.fileWatchingEnabledshould be documented, explaining its purpose for reducing CPU usage with multiple worktrees/instances.Additional Notes
This PR addresses @Jerrill's question in issue #8131:
Feedback and guidance are welcome!
Get in Touch
N/A - Automated contribution