Skip to content

Conversation

@MuriloFP
Copy link
Contributor

@MuriloFP MuriloFP commented Jul 23, 2025

Related GitHub Issue

Closes: #5662

Roo Code Task Context (Optional)

No Roo Code task context for this PR

Description

This PR addresses the issue where Roo would sometimes try to use semantic search even when indexing wasn't complete. The solution implements runtime state checking as suggested by @daniel-lxs in the issue comments.

Key implementation details:

  • The codebase_search tool is now always included in the tool list instead of being hidden
  • Added runtime state checking in the tool itself that provides user-friendly feedback
  • Different messages are shown for each indexing state (Standby, Indexing, Error)
  • Suggests using file reading tools (read_file, search_files) as alternatives when semantic search is unavailable
  • Removed the strict state check in the search service that was throwing errors

Design choice: Following the suggestion in the comments, I kept the tool always available and added runtime checks instead of hiding it. This makes state transitions smoother and helps users understand why semantic search isn't being used.

Test Procedure

Automated tests:

  • Added comprehensive unit tests in src/core/tools/__tests__/codebaseSearchTool.spec.ts
  • All tests pass: cd src && npx vitest run core/tools/__tests__/codebaseSearchTool.spec.ts
  • Existing tests still pass: cd src && npx vitest run core/prompts/sections/__tests__/

Manual testing:

  1. Disable code indexing in settings
  2. Try to use semantic search - should see a message about indexing being disabled
  3. Enable indexing but don't wait for it to complete
  4. Try to use semantic search - should see a message about indexing in progress
  5. Wait for indexing to complete
  6. Try to use semantic search - should work normally

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

No UI changes in this PR

Documentation Updates

  • No documentation updates are required.

Additional Notes

This implementation follows the approach suggested by @daniel-lxs in the issue comments. The tool remains available at all times but provides clear feedback about the indexing state, making the experience more transparent for users.

Get in Touch

@MuriloFP


Important

Improves codebase_search tool by adding runtime state checks for indexing, providing user feedback, and updating tests.

  • Behavior:
    • codebase_search tool now always included in tool list, with runtime state checks for user feedback.
    • Provides messages for indexing states: Standby, Indexing, Error.
    • Suggests alternative tools when semantic search is unavailable.
    • Removed strict state check in search-service.ts.
  • Tests:
    • Added unit tests in codebaseSearchTool.spec.ts for new state handling logic.
    • Tests cover all indexing states and feature configuration scenarios.
  • Misc:
    • Minor changes in index.ts to conditionally exclude codebase_search based on feature configuration.

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

MuriloFP and others added 25 commits July 3, 2025 15:26
- Always show codebase_search tool in the tool list
- Add runtime state checking with user-friendly feedback
- Provide clear messages for each indexing state (Standby, Indexing, Error)
- Suggest alternative tools when semantic search is unavailable
- Add comprehensive tests for the new behavior

This ensures Roo doesn't try to use semantic search when indexing
is incomplete and provides clear feedback to users about the current state.
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 23, 2025
- Added translations for codeIndex.errorState to all 17 language files
- Ensures consistent error messaging across all supported languages
@MuriloFP
Copy link
Contributor Author

Hi @daniel-lxs, I've implemented all your suggestions:

  1. Internationalized the error message in search-service.ts

    • Added the translation key to English embeddings.json
    • Added translations to all 17 other language files
  2. Added telemetry tracking when users encounter non-indexed states

    • Using the existing TOOL_USED event with additional metadata
    • Tracks the indexing state and whether a query was provided
  3. Extracted state message generation into a separate function

    • Created getIndexingStateMessage() function for better maintainability
    • Makes it easier to update messages in one place
  4. Simplified the test cases to reduce redundancy

    • Combined the three separate state tests into a single parameterized test
    • Removed the incomplete test for hasQuery tracking

All tests are passing and CI checks are green. Thanks for the great suggestions!

@MuriloFP MuriloFP moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 23, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jul 24, 2025
- Updated tool availability logic to exclude codebase_search when state is not 'Indexed'
- Added comprehensive tests for tool availability based on indexing state
- Removed tests for runtime feedback since tool won't be available in non-indexed states
- Addresses review feedback from @daniel-lxs
@MuriloFP MuriloFP moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 25, 2025
@daniel-lxs
Copy link
Member

@MuriloFP I missed the fact that hiding the tool from the prompt when it's indexing will probably cause issues when files are changed and the service enters the "Indexing" state again, maybe we should introduce a new state so that we can differentiate between the initial scan and the indexing process that happened when a file is updated to prevent this.

What you do you think?

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jul 25, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 27, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jul 28, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Changes Requested size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Please add proper file search or reading guideline including indexing state context.

3 participants