ensure workspace index is disabled for no auth, disable semantic search provider (#1155)

This commit is contained in:
SteVen Batten
2025-09-26 14:43:03 +00:00
committed by GitHub
parent 9e1bdf2c8a
commit e5f09d2fc9
5 changed files with 29 additions and 2 deletions
@@ -162,6 +162,13 @@ export class ConversationFeature implements IExtensionContribution {
return;
} else {
this._searchProviderRegistered = true;
// Don't register for no auth user
if (this.authenticationService.copilotToken?.isNoAuthUser) {
this.logService.debug('ConversationFeature: Skipping search provider registration - no GitHub session available');
return;
}
return vscode.workspace.registerAITextSearchProvider('file', this.instantiationService.createInstance(SemanticSearchTextSearchProvider));
}
}
@@ -13,6 +13,7 @@ import { IPromptPathRepresentationService } from '../../../../../platform/prompt
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry';
import { getWorkspaceFileDisplayPath, IWorkspaceService } from '../../../../../platform/workspace/common/workspaceService';
import { KeywordItem, ResolvedWorkspaceChunkQuery, WorkspaceChunkQuery } from '../../../../../platform/workspaceChunkSearch/common/workspaceChunkSearch';
import { LocalEmbeddingsIndexStatus } from '../../../../../platform/workspaceChunkSearch/node/embeddingsChunkSearch';
import { IWorkspaceChunkSearchService, WorkspaceChunkSearchResult } from '../../../../../platform/workspaceChunkSearch/node/workspaceChunkSearchService';
import { GlobIncludeOptions } from '../../../../../util/common/glob';
import { createFencedCodeBlock, getLanguageId } from '../../../../../util/common/markdown';
@@ -45,7 +46,7 @@ export const MAX_CHUNK_TOKEN_COUNT = 32_000;
export const MAX_TOOL_CHUNK_TOKEN_COUNT = 20_000;
type WorkspaceChunksState = {
readonly result: WorkspaceChunkSearchResult;
readonly result?: WorkspaceChunkSearchResult;
};
export interface ChunksToolProps extends BasePromptElementProps {
@@ -73,6 +74,11 @@ export class WorkspaceChunks extends PromptElement<ChunksToolProps, WorkspaceChu
}
override async prepare(sizing: PromptSizing, progress: vscode.Progress<vscode.ChatResponsePart> | undefined, token = CancellationToken.None): Promise<WorkspaceChunksState> {
const indexState = await this.workspaceChunkSearch.getIndexState();
if (indexState.localIndexState.status === LocalEmbeddingsIndexStatus.Disabled && indexState.remoteIndexState.status === 'disabled') {
return {};
}
const searchResult = await logExecTime(this.logService, 'workspaceContext.perf.prepareWorkspaceChunks', () => {
return raceCancellationError(
this.workspaceChunkSearch.searchFileChunks({
@@ -115,6 +121,10 @@ export class WorkspaceChunks extends PromptElement<ChunksToolProps, WorkspaceChu
}
override render(state: WorkspaceChunksState, sizing: PromptSizing): PromptPiece<any, any> | undefined {
if (state.result === undefined) {
return <TextChunk>The workspace index is not available at this time.</TextChunk>;
}
return <WorkspaceChunkList
result={state.result}
referencesOut={this.props.referencesOut}
@@ -272,6 +272,9 @@ export class ChatStatusWorkspaceIndexingStatus extends Disposable {
},
};
case LocalEmbeddingsIndexStatus.Disabled:
return undefined;
case LocalEmbeddingsIndexStatus.TooManyFilesForAnyIndexing:
default:
return {
@@ -28,6 +28,7 @@ import { WorkspaceChunkEmbeddingsIndex, WorkspaceChunkEmbeddingsIndexState } fro
import { IWorkspaceFileIndex } from './workspaceFileIndex';
export enum LocalEmbeddingsIndexStatus {
Disabled = 'disabled',
Unknown = 'unknown',
UpdatingIndex = 'updatingIndex',
@@ -19,6 +19,7 @@ import { Disposable, IDisposable } from '../../../util/vs/base/common/lifecycle'
import { StopWatch } from '../../../util/vs/base/common/stopwatch';
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
import { ChatResponseProgressPart2 } from '../../../vscodeTypes';
import { IAuthenticationService } from '../../authentication/common/authentication';
import { IAuthenticationChatUpgradeService } from '../../authentication/common/authenticationUpgrade';
import { FileChunk, FileChunkAndScore } from '../../chunking/common/chunk';
import { MAX_CHUNK_SIZE_TOKENS } from '../../chunking/node/naiveChunker';
@@ -118,6 +119,7 @@ export class WorkspaceChunkSearchService extends Disposable implements IWorkspac
constructor(
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IAuthenticationService private readonly _authenticationService: IAuthenticationService,
@ILogService private readonly _logService: ILogService,
) {
super();
@@ -128,6 +130,10 @@ export class WorkspaceChunkSearchService extends Disposable implements IWorkspac
}
private async tryInit(silent: boolean): Promise<WorkspaceChunkSearchServiceImpl | undefined> {
if (!this._authenticationService.copilotToken || this._authenticationService.copilotToken.isNoAuthUser) {
return undefined;
}
if (this._impl) {
return this._impl;
}
@@ -161,7 +167,7 @@ export class WorkspaceChunkSearchService extends Disposable implements IWorkspac
repos: [],
},
localIndexState: {
status: LocalEmbeddingsIndexStatus.Unknown,
status: !this._authenticationService.copilotToken || this._authenticationService.copilotToken.isNoAuthUser ? LocalEmbeddingsIndexStatus.Disabled : LocalEmbeddingsIndexStatus.Unknown,
getState: async () => undefined,
}
};