-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: handle codebase search indexing state properly (#5662) #6118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: handle codebase search indexing state properly (#5662) #6118
Conversation
- 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.
- Only show codebase_search when feature is enabled AND configured - Tool is now visible during indexing (Standby/Indexing states) - Added test to verify tool availability during initialization
Fixed the an issue pointed out. The codebase_search tool is now:
This maintains the original behavior for disabled/unconfigured states while adding the new runtime state checking for when indexing is in progress. |
2ff2b04
to
5ce9ea5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @MuriloFP, I left some minor suggestions.
Let me know what you think
// Allow search during Indexing too | ||
throw new Error(`Code index is not ready for search. Current state: ${currentState}`) | ||
if (currentState === "Error") { | ||
throw new Error(`Code index is in error state. Please check your configuration.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a facing error can we take the opportunity to internationalize it?
src/core/tools/codebaseSearchTool.ts
Outdated
@@ -82,6 +82,33 @@ export async function codebaseSearchTool( | |||
throw new Error("Code Indexing is not configured (Missing OpenAI Key or Qdrant URL).") | |||
} | |||
|
|||
// Check indexing state at runtime | |||
const indexingState = manager.state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add telemetry here to track when users encounter non-indexed states? This could help understand how often users try to use semantic search before indexing is complete:
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_SEARCH_ATTEMPTED, {
state: indexingState,
query: query ? 'provided' : 'missing'
});
This would provide valuable insights into user behavior patterns.
src/core/tools/codebaseSearchTool.ts
Outdated
const indexingState = manager.state | ||
if (indexingState !== "Indexed") { | ||
let stateMessage = "" | ||
switch (indexingState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the state message generation into a separate function for better maintainability and potential reuse:
function getIndexingStateMessage(state: IndexingState): string {
switch (state) {
case "Standby":
return "Code indexing has not started yet. Please wait for the initial indexing to complete.";
case "Indexing":
return "Code indexing is currently in progress. Semantic search will be available once indexing is complete.";
case "Error":
return "Code indexing encountered an error. Please check your configuration and try again.";
default:
return `Code indexing is in an unexpected state: ${state}`;
}
}
This would make it easier to update messages in one place and potentially reuse them in other parts of the codebase.
- Added translations for codeIndex.errorState to all 17 language files - Ensures consistent error messaging across all supported languages
Hi @daniel-lxs, I've implemented all your suggestions:
All tests are passing and CI checks are green. Thanks for the great suggestions! |
!(codeIndexManager.isFeatureEnabled && codeIndexManager.isFeatureConfigured && codeIndexManager.isInitialized) | ||
) { | ||
// Note: We still show the tool when it's initialized but indexing is in progress | ||
if (!codeIndexManager || !codeIndexManager.isFeatureEnabled || !codeIndexManager.isFeatureConfigured) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to also not show it if it's not finished indexing
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:
codebase_search
tool is now always included in the tool list instead of being hiddenDesign 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:
src/core/tools/__tests__/codebaseSearchTool.spec.ts
cd src && npx vitest run core/tools/__tests__/codebaseSearchTool.spec.ts
cd src && npx vitest run core/prompts/sections/__tests__/
Manual testing:
Pre-Submission Checklist
Screenshots / Videos
No UI changes in this PR
Documentation Updates
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.codebase_search
tool now always included in tool list, with runtime state checks for user feedback.search-service.ts
.codebaseSearchTool.spec.ts
for new state handling logic.index.ts
to conditionally excludecodebase_search
based on feature configuration.This description was created by
for 5ce9ea5. You can customize this summary. It will automatically update as commits are pushed.