@@ -230,6 +230,7 @@ import { DisplayFindings } from './tools/qCodeAnalysis/displayFindings'
230230import { IDE } from '../../shared/constants'
231231import { IdleWorkspaceManager } from '../workspaceContext/IdleWorkspaceManager'
232232import escapeHTML = require( 'escape-html' )
233+ import { SemanticSearch } from './tools/workspaceContext/semanticSearch'
233234
234235type ChatHandlers = Omit <
235236 LspHandlers < Chat > ,
@@ -1906,7 +1907,9 @@ export class AgenticChatController implements ChatHandlers {
19061907 }
19071908 case CodeReview . toolName :
19081909 case DisplayFindings . toolName :
1909- // no need to write tool message for CodeReview or DisplayFindings
1910+ // no need to write tool message for CodeReview or DisplayFindings
1911+ case SemanticSearch . toolName :
1912+ // For internal A/B we don't need tool message
19101913 break
19111914 // — DEFAULT ⇒ Only MCP tools, but can also handle generic tool execution messages
19121915 default :
@@ -2123,6 +2126,9 @@ export class AgenticChatController implements ChatHandlers {
21232126 } )
21242127 }
21252128 break
2129+ case SemanticSearch . toolName :
2130+ await this . #handleSemanticSearchToolResult( toolUse , result , session , chatResultStream )
2131+ break
21262132 // — DEFAULT ⇒ MCP tools
21272133 default :
21282134 await this . #handleMcpToolResult( toolUse , result , session , chatResultStream )
@@ -4648,6 +4654,64 @@ export class AgenticChatController implements ChatHandlers {
46484654 } )
46494655 }
46504656
4657+ async #handleSemanticSearchToolResult(
4658+ toolUse : ToolUse ,
4659+ result : any ,
4660+ session : ChatSessionService ,
4661+ chatResultStream : AgenticChatResultStream
4662+ ) : Promise < void > {
4663+ // Early return if toolUseId is undefined
4664+ if ( ! toolUse . toolUseId ) {
4665+ this . #log( `Cannot handle semantic search tool result: missing toolUseId` )
4666+ return
4667+ }
4668+
4669+ // Format the tool result and input as JSON strings
4670+ const toolInput = JSON . stringify ( toolUse . input , null , 2 )
4671+ const toolResultContent = typeof result === 'string' ? result : JSON . stringify ( result , null , 2 )
4672+
4673+ const toolResultCard : ChatMessage = {
4674+ type : 'tool' ,
4675+ messageId : toolUse . toolUseId ,
4676+ summary : {
4677+ content : {
4678+ header : {
4679+ icon : 'tools' ,
4680+ body : `${ SemanticSearch . toolName } ` ,
4681+ fileList : undefined ,
4682+ } ,
4683+ } ,
4684+ collapsedContent : [
4685+ {
4686+ header : {
4687+ body : 'Parameters' ,
4688+ } ,
4689+ body : `\`\`\`json\n${ toolInput } \n\`\`\`` ,
4690+ } ,
4691+ {
4692+ header : {
4693+ body : 'Result' ,
4694+ } ,
4695+ body : `\`\`\`json\n${ toolResultContent } \n\`\`\`` ,
4696+ } ,
4697+ ] ,
4698+ } ,
4699+ }
4700+
4701+ // Get the stored blockId for this tool use
4702+ const cachedToolUse = session . toolUseLookup . get ( toolUse . toolUseId )
4703+ const cachedButtonBlockId = ( cachedToolUse as any ) ?. cachedButtonBlockId
4704+
4705+ if ( cachedButtonBlockId !== undefined ) {
4706+ // Update the existing card with the results
4707+ await chatResultStream . overwriteResultBlock ( toolResultCard , cachedButtonBlockId )
4708+ } else {
4709+ // Fallback to creating a new card
4710+ this . #log( `Warning: No blockId found for tool use ${ toolUse . toolUseId } , creating new card` )
4711+ await chatResultStream . writeResultBlock ( toolResultCard )
4712+ }
4713+ }
4714+
46514715 scheduleABTestingFetching ( userContext : UserContext | undefined ) {
46524716 if ( ! userContext ) {
46534717 return
@@ -4671,8 +4735,8 @@ export class AgenticChatController implements ChatHandlers {
46714735 codeWhispererServiceToken
46724736 . listFeatureEvaluations ( { userContext } )
46734737 . then ( result => {
4674- const feature = result . featureEvaluations ?. find (
4675- feature => feature . feature === 'MaestroWorkspaceContext'
4738+ const feature = result . featureEvaluations ?. find ( feature =>
4739+ [ 'MaestroWorkspaceContext' , 'SematicSearchTool' ] . includes ( feature . feature )
46764740 )
46774741 if ( feature ) {
46784742 this . #abTestingAllocation = {
0 commit comments