File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,11 @@ export function getToolDescriptionsForMode(
101101 // Add always available tools
102102 ALWAYS_AVAILABLE_TOOLS . forEach ( ( tool ) => tools . add ( tool ) )
103103
104- // Note: codebase_search is now always included in the tool list
105- // The tool itself will check the indexing state at runtime and provide appropriate feedback
104+ // Conditionally exclude codebase_search if feature is disabled or not configured
105+ // Note: We still show the tool when it's initialized but indexing is in progress
106+ if ( ! codeIndexManager || ! codeIndexManager . isFeatureEnabled || ! codeIndexManager . isFeatureConfigured ) {
107+ tools . delete ( "codebase_search" )
108+ }
106109
107110 // Conditionally exclude update_todo_list if disabled in settings
108111 if ( settings ?. todoListEnabled === false ) {
Original file line number Diff line number Diff line change @@ -243,6 +243,37 @@ describe("codebaseSearchTool", () => {
243243 } ) ,
244244 )
245245 } )
246+
247+ it ( "should be available when enabled and configured but not initialized" , async ( ) => {
248+ // This test verifies that the tool is available even when indexing is not complete
249+ // The tool itself will handle the state checking
250+ mockCodeIndexManager . isFeatureEnabled = true
251+ mockCodeIndexManager . isFeatureConfigured = true
252+ mockCodeIndexManager . isInitialized = false
253+ mockCodeIndexManager . state = "Standby"
254+
255+ const block : ToolUse = {
256+ type : "tool_use" ,
257+ name : "codebase_search" ,
258+ params : { query : "test query" } ,
259+ partial : false ,
260+ }
261+
262+ await codebaseSearchTool (
263+ mockTask ,
264+ block ,
265+ mockAskApproval ,
266+ mockHandleError ,
267+ mockPushToolResult ,
268+ mockRemoveClosingTag ,
269+ )
270+
271+ // Should not throw an error, but should provide feedback about the state
272+ expect ( mockHandleError ) . not . toHaveBeenCalled ( )
273+ expect ( mockPushToolResult ) . toHaveBeenCalledWith (
274+ expect . stringContaining ( "Semantic search is not available yet (currently Standby)" ) ,
275+ )
276+ } )
246277 } )
247278
248279 describe ( "parameter validation" , ( ) => {
You can’t perform that action at this time.
0 commit comments