Skip to content

Conversation

@MuriloFP
Copy link
Contributor

@MuriloFP MuriloFP commented Jul 18, 2025

Related GitHub Issue

Closes: #5662

Roo Code Task Context (Optional)

No Roo Code task context for this PR

Description

This PR implements a runtime check for the indexing state in the codebase_search tool, as suggested by @daniel-lxs in the issue comments. Instead of hiding the tool from the tool list when indexing is not complete (as attempted in PR #5663), this solution:

  • Keeps the codebase_search tool always available in the tool list
  • Performs a runtime check when the tool is actually used
  • Provides a clear, informative error message when indexing is not complete
  • Guides users to use alternative tools (read_file, search_files) while indexing is in progress

The key implementation detail is the addition of a state check before executing the search:

if (indexingState !== 'Indexed') {
    throw new Error(`Semantic search isn't ready yet (currently ${indexingState}). The codebase is still being indexed. Please try again once indexing is complete, or use other tools like read_file or search_files for now.`)
}

This approach provides better user experience by:

  1. Making state transitions smoother (e.g., when indexing finishes mid-conversation)
  2. Keeping the logic in one place (inside the tool)
  3. Helping users understand why semantic search isn't available instead of silently hiding it

Test Procedure

Unit Tests:

  • Created comprehensive test suite in src/core/tools/__tests__/codebaseSearchTool.spec.ts
  • Tests cover all indexing states: 'Standby', 'Indexing', 'Error', and 'Indexed'
  • Tests verify the error messages are shown correctly for non-'Indexed' states
  • All 10 new tests pass
  • All existing tests continue to pass (238 test files, 2906 tests)

Manual Testing Steps:

  1. Disable code indexing in settings and try to use codebase_search - should get "disabled" error
  2. Enable indexing but don't configure (missing API key) - should get "not configured" error
  3. Start indexing and immediately try to use codebase_search - should get "currently Indexing" error
  4. Wait for indexing to complete and use codebase_search - should work normally

To run the tests:

cd src && npx vitest core/tools/__tests__/codebaseSearchTool.spec.ts

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 suggestion from @daniel-lxs in the issue comments, which provides a better user experience than the approach in PR #5663. The error messages are designed to be informative and guide users to alternative solutions while waiting for indexing to complete.

Get in Touch

Discord username not provided


Important

Adds runtime indexing state check to codebaseSearchTool and comprehensive tests for various states and configurations.

  • Behavior:
    • Adds runtime check in codebaseSearchTool to ensure indexing state is 'Indexed' before proceeding.
    • Throws error with informative message if indexing state is 'Indexing', 'Standby', or 'Error'.
    • Keeps codebase_search tool available in tool list regardless of indexing state.
  • Tests:
    • Adds codebaseSearchTool.spec.ts with tests for indexing states: 'Standby', 'Indexing', 'Error', and 'Indexed'.
    • Tests for feature availability: disabled and not configured states.
    • Tests for parameter validation and search results handling.
  • Misc:
    • Guides users to alternative tools if indexing is incomplete.

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

MuriloFP and others added 22 commits July 3, 2025 15:26
…eInc#5662)

- Check if indexing is complete (state === 'Indexed') before searching
- Provide clear error message with current indexing state
- Guide users to use alternative tools while indexing
- Add comprehensive test coverage for all indexing states

This ensures semantic search is only used when the index is ready,
preventing confusion and failed search attempts during indexing.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 18, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 18, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 18, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 18, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 21, 2025
@daniel-lxs
Copy link
Member

I think this should be handled differently.

We should distinguish between the initial full-codebase scan and the file watcher indexing state. That way, file changes don’t end up disabling the tool.

If indexing is enabled but not ready, we should show a warning to the user. The tool should also be excluded from the system prompt until it's fully ready.

@daniel-lxs daniel-lxs closed this Jul 21, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Jul 21, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 21, 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 lgtm This PR has been approved by a maintainer PR - Needs Preliminary Review size:L This PR changes 100-499 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