Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 3, 2026

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:

  1. New workspace-scoped setting: Added roo-cline.codeIndex.fileWatchingEnabled (default: true) with "scope": "resource" so each workspace/worktree can have independent settings.

  2. New IndexedPaused state: Added to the indexing state machine to distinguish between "Indexed with active watcher" and "Indexed without watcher".

  3. Conditional watcher start: Modified the orchestrator to check isFileWatchingEnabled after initial indexing completes. If disabled, the state transitions to IndexedPaused instead of starting the file watcher.

  4. 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:

  • Run initial indexing in each worktree to populate the search index
  • Set roo-cline.codeIndex.fileWatchingEnabled: false in worktrees where you want to reduce CPU usage
  • The codebase_search tool will still work using the existing index
  • Re-run indexing manually when significant changes occur in paused worktrees

Test Procedure

  1. Unit tests: Added comprehensive tests in src/services/code-index/__tests__/file-watching-pause.spec.ts covering:

    • File watcher is NOT started when setting is disabled
    • File watcher IS started when setting is enabled (default)
    • State transitions to IndexedPaused when file watching is disabled
    • State transitions to Indexed when file watching is enabled
    • Re-indexing works from IndexedPaused state
    • Manager exposes isFileWatchingEnabled getter
    • IndexedPaused state has a default message
    • ConfigManager returns true by default when setting is not configured
  2. Run tests: cd src && npx vitest run services/code-index/__tests__/file-watching-pause.spec.ts

  3. Manual testing: Open workspace settings and toggle roo-cline.codeIndex.fileWatchingEnabled, then trigger indexing to observe state changes.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a backend feature with no UI changes.

Documentation Updates

  • Yes, documentation updates are required. The new setting roo-cline.codeIndex.fileWatchingEnabled should be documented, explaining its purpose for reducing CPU usage with multiple worktrees/instances.

Additional Notes

This PR addresses @Jerrill's question in issue #8131:

Is there a way to enable an initial indexing to support codebase_search, but pause file-watching, which is a very CPU expensive operation when there is one instance much less multiples?

Feedback and guidance are welcome!

Get in Touch

N/A - Automated contribution

This addresses Issue #8131 by adding a workspace-scoped setting
roo-cline.codeIndex.fileWatchingEnabled that allows users to:
- Enable initial indexing for codebase_search functionality
- Pause file-watching to reduce CPU usage (especially useful with git worktrees)
- Each workspace/worktree maintains independent settings

Changes:
- Add fileWatchingEnabled setting in package.json (scope: resource)
- Add IndexedPaused state to the indexing state machine
- Update ConfigManager with isFileWatchingEnabled getter
- Modify orchestrator to conditionally start/stop file watcher
- Add comprehensive tests for the new functionality
@roomote
Copy link
Contributor Author

roomote bot commented Jan 3, 2026

Rooviewer Clock   See task on Roo Cloud

Review completed. The implementation correctly adds a workspace-scoped setting to pause file-watching after initial indexing. One minor consistency issue was identified:

  • Use i18n translation keys for new IndexedPaused state messages in orchestrator.ts to match the existing code pattern

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

Comment on lines +206 to +209
this.stateManager.setSystemState(
"IndexedPaused",
"Index ready. File watching disabled. Use 'Re-Index' to update.",
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This message uses a hardcoded string while the existing code pattern (e.g., line 202) uses the t() function for i18n translations. For consistency and to support non-English locales, consider adding translation keys for these new messages.

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 Jan 3, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 6, 2026
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 6, 2026
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.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Per-workspace control for Codebase Indexing (reduce GPU)

3 participants