@@ -19,7 +19,6 @@ import { StopWatch } from '../../../util/vs/base/common/stopwatch';
1919import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation' ;
2020import { ChatResponseProgressPart2 , ChatResponseWarningPart } from '../../../vscodeTypes' ;
2121import { IAuthenticationService } from '../../authentication/common/authentication' ;
22- import { IAuthenticationChatUpgradeService } from '../../authentication/common/authenticationUpgrade' ;
2322import { FileChunk , FileChunkAndScore } from '../../chunking/common/chunk' ;
2423import { MAX_CHUNK_SIZE_TOKENS } from '../../chunking/node/naiveChunker' ;
2524import { distance , Embedding , EmbeddingDistance , Embeddings , EmbeddingType , IEmbeddingsComputer } from '../../embeddings/common/embeddingsComputer' ;
@@ -29,14 +28,13 @@ import { logExecTime, LogExecTime } from '../../log/common/logExecTime';
2928import { ILogService } from '../../log/common/logService' ;
3029import { IChatEndpoint } from '../../networking/common/networking' ;
3130import { ISimulationTestContext } from '../../simulationTestContext/common/simulationTestContext' ;
32- import { IExperimentationService } from '../../telemetry/common/nullExperimentationService' ;
3331import { ITelemetryService } from '../../telemetry/common/telemetry' ;
3432import { getWorkspaceFileDisplayPath , IWorkspaceService } from '../../workspace/common/workspaceService' ;
3533import { IGithubAvailableEmbeddingTypesService } from '../common/githubAvailableEmbeddingTypes' ;
3634import { IRerankerService } from '../common/rerankerService' ;
37- import { StrategySearchResult , StrategySearchSizing , WorkspaceChunkQuery , WorkspaceChunkQueryWithEmbeddings , WorkspaceChunkSearchOptions , WorkspaceChunkSearchStrategyId , WorkspaceSearchAlert } from '../common/workspaceChunkSearch' ;
35+ import { StrategySearchResult , StrategySearchSizing , WorkspaceChunkQuery , WorkspaceChunkQueryWithEmbeddings , WorkspaceChunkSearchOptions , WorkspaceSearchAlert } from '../common/workspaceChunkSearch' ;
3836import { CodeSearchChunkSearch , CodeSearchRemoteIndexState } from './codeSearch/codeSearchChunkSearch' ;
39- import { BuildIndexTriggerReason , CodeSearchRepoStatus , TriggerIndexingError } from './codeSearch/codeSearchRepo' ;
37+ import { BuildIndexTriggerReason , TriggerIndexingError } from './codeSearch/codeSearchRepo' ;
4038import { IWorkspaceFileIndex } from './workspaceFileIndex' ;
4139
4240const maxEmbeddingSpread = 0.65 ;
@@ -49,7 +47,6 @@ interface ScoredFileChunk<T extends FileChunk = FileChunk> {
4947export interface WorkspaceChunkSearchResult {
5048 readonly chunks : readonly FileChunkAndScore [ ] ;
5149 readonly alerts ?: readonly WorkspaceSearchAlert [ ] ;
52- readonly strategy ?: string ;
5350}
5451
5552export interface WorkspaceChunkSearchSizing {
@@ -88,17 +85,12 @@ export interface IWorkspaceChunkSearchService extends IDisposable {
8885}
8986
9087
91- interface StrategySearchOk {
92- readonly strategy : WorkspaceChunkSearchStrategyId ;
93- readonly result : StrategySearchResult ;
94- }
95-
9688interface StrategySearchErr {
9789 readonly errorDiagMessage : string ;
9890 alerts ?: readonly WorkspaceSearchAlert [ ] ;
9991}
10092
101- type StrategySearchOutcome = Result < StrategySearchOk , StrategySearchErr > ;
93+ type StrategySearchOutcome = Result < StrategySearchResult , StrategySearchErr > ;
10294
10395export class WorkspaceChunkSearchService extends Disposable implements IWorkspaceChunkSearchService {
10496 declare readonly _serviceBrand : undefined ;
@@ -213,9 +205,7 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
213205 constructor (
214206 private readonly _embeddingType : EmbeddingType ,
215207 @IInstantiationService instantiationService : IInstantiationService ,
216- @IAuthenticationChatUpgradeService private readonly _authUpgradeService : IAuthenticationChatUpgradeService ,
217208 @IEmbeddingsComputer private readonly _embeddingsComputer : IEmbeddingsComputer ,
218- @IExperimentationService private readonly _experimentationService : IExperimentationService ,
219209 @IIgnoreService private readonly _ignoreService : IIgnoreService ,
220210 @ILogService private readonly _logService : ILogService ,
221211 @IRerankerService private readonly _rerankerService : IRerankerService ,
@@ -236,14 +226,6 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
236226 250
237227 ) ( ( ) => this . _onDidChangeIndexState . fire ( ) ) ) ;
238228
239- this . _register ( this . _authUpgradeService . onDidGrantAuthUpgrade ( ( ) => {
240- if ( this . _experimentationService . getTreatmentVariable < boolean > ( 'copilotchat.workspaceChunkSearch.shouldRemoteIndexOnAuthUpgrade' ) ?? true ) {
241- void this . triggerRemoteIndexing ( 'auto' , ( ) => { } , new TelemetryCorrelationId ( 'onDidGrantAuthUpgrade' ) , CancellationToken . None ) . catch ( e => {
242- // noop
243- } ) ;
244- }
245- } ) ) ;
246-
247229 /* __GDPR__
248230 "workspaceChunkSearch.created" : {
249231 "owner": "mjbvz",
@@ -263,12 +245,7 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
263245 }
264246
265247 async isAvailable ( ) : Promise < boolean > {
266- if ( this . _experimentationService . getTreatmentVariable < boolean > ( 'copilotchat.workspaceChunkSearch.markAllSearchesSlow' ) ) {
267- return false ;
268- }
269-
270- const indexState = await this . getIndexState ( ) ;
271- return ( indexState . remoteIndexState . status === 'loaded' && indexState . remoteIndexState . repos . length > 0 && indexState . remoteIndexState . repos . every ( repo => repo . status === CodeSearchRepoStatus . Ready ) ) ;
248+ return this . _codeSearchChunkSearch . isAvailable ( new TelemetryCorrelationId ( 'WorkspaceChunkSearchServiceImpl.isAvailable' ) , false , CancellationToken . None ) ;
272249 }
273250
274251 triggerRemoteIndexing ( trigger : BuildIndexTriggerReason , onProgress : ( message : string ) => void , telemetryInfo : TelemetryCorrelationId , token : CancellationToken ) : Promise < Result < true , TriggerIndexingError > > {
@@ -325,7 +302,7 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
325302 }
326303 */
327304 this . _telemetryService . sendMSFTTelemetryEvent ( 'workspaceChunkSearchStrategy' , {
328- strategy : searchResult . isOk ( ) ? searchResult . val . strategy : 'none' ,
305+ strategy : searchResult . isOk ( ) ? 'codesearch' : 'none' , // For backwards compatibility with existing telemetry only
329306 errorDiagMessage : searchResult . isError ( ) ? searchResult . err . errorDiagMessage : undefined ,
330307 embeddingType : this . _embeddingType . id ,
331308 workspaceSearchSource : telemetryInfo . callTracker . toString ( ) ,
@@ -348,9 +325,9 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
348325 } ;
349326 }
350327
351- this . _logService . trace ( `WorkspaceChunkSearch.searchFileChunks: found ${ searchResult . val . result . chunks . length } chunks using ' ${ searchResult . val . strategy } ' ` ) ;
328+ this . _logService . trace ( `WorkspaceChunkSearch.searchFileChunks: found ${ searchResult . val . chunks . length } chunks` ) ;
352329
353- const filteredChunks = await raceCancellationError ( this . filterIgnoredChunks ( searchResult . val . result . chunks ) , token ) ;
330+ const filteredChunks = await raceCancellationError ( this . filterIgnoredChunks ( searchResult . val . chunks ) , token ) ;
354331 if ( this . _simulationTestContext . isInSimulationTests ) {
355332 if ( ! filteredChunks . length ) {
356333 throw new Error ( 'No chunks returned' ) ;
@@ -360,7 +337,7 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
360337 const filteredResult = {
361338 ...searchResult . val ,
362339 result : {
363- alerts : searchResult . val . result . alerts ,
340+ alerts : searchResult . val . alerts ,
364341 chunks : filteredChunks ,
365342 }
366343 } ;
@@ -372,7 +349,6 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
372349 return {
373350 chunks : reranked . slice ( 0 , this . getMaxChunks ( sizing ) ) ,
374351 alerts : filteredResult . result . alerts ,
375- strategy : filteredResult . strategy ,
376352 } ;
377353 } catch ( e ) {
378354 this . _logService . error ( e , 'Reranker service failed; falling back to local rerank' ) ;
@@ -433,17 +409,14 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
433409
434410 const result = await raceCancellationError ( this . _codeSearchChunkSearch . searchWorkspace ( sizing , query , options , telemetryInfo , token ) , token ) ;
435411 if ( result ) {
436- return Result . ok < StrategySearchOk > ( {
437- strategy : this . _codeSearchChunkSearch . id ,
438- result : result ,
439- } ) ;
412+ return Result . ok < StrategySearchResult > ( result ) ;
440413 }
441414 } catch ( e ) {
442415 if ( isCancellationError ( e ) ) {
443416 throw e ;
444417 }
445418
446- this . _logService . error ( e , `Error during ${ this . _codeSearchChunkSearch . id } search` ) ;
419+ this . _logService . error ( e , `Error during code search chunk search` ) ;
447420 }
448421
449422 return Result . error < StrategySearchErr > ( {
@@ -477,13 +450,12 @@ class WorkspaceChunkSearchServiceImpl extends Disposable implements IWorkspaceCh
477450 }
478451
479452 @LogExecTime ( self => self . _logService , 'WorkspaceChunkSearch::rerankResultIfNeeded' )
480- private async rerankResultIfNeeded ( query : WorkspaceChunkQueryWithEmbeddings , result : StrategySearchOk , maxResults : number , telemetryInfo : TelemetryCorrelationId , progress : vscode . Progress < vscode . ChatResponsePart > | undefined , token : CancellationToken ) : Promise < WorkspaceChunkSearchResult > {
481- const chunks = result . result . chunks ;
453+ private async rerankResultIfNeeded ( query : WorkspaceChunkQueryWithEmbeddings , result : StrategySearchResult , maxResults : number , telemetryInfo : TelemetryCorrelationId , progress : vscode . Progress < vscode . ChatResponsePart > | undefined , token : CancellationToken ) : Promise < WorkspaceChunkSearchResult > {
454+ const chunks = result . chunks ;
482455 const orderedChunks = await this . rerankChunks ( query , chunks , maxResults , telemetryInfo , progress , token ) ;
483456 return {
484457 chunks : orderedChunks ,
485- alerts : result . result . alerts ,
486- strategy : result . strategy ,
458+ alerts : result . alerts ,
487459 } ;
488460 }
489461
0 commit comments