From e5f09d2fc93c6d1343e5ef360a2bf79d20f8aa44 Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Fri, 26 Sep 2025 07:43:03 -0700 Subject: [PATCH] ensure workspace index is disabled for no auth, disable semantic search provider (#1155) --- .../conversation/vscode-node/conversationFeature.ts | 7 +++++++ .../node/panel/workspace/workspaceContext.tsx | 12 +++++++++++- .../vscode-node/workspaceIndexingStatus.ts | 3 +++ .../node/embeddingsChunkSearch.ts | 1 + .../node/workspaceChunkSearchService.ts | 8 +++++++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/extensions/copilot/src/extension/conversation/vscode-node/conversationFeature.ts b/extensions/copilot/src/extension/conversation/vscode-node/conversationFeature.ts index ce5e7b4585c..fec26d169af 100644 --- a/extensions/copilot/src/extension/conversation/vscode-node/conversationFeature.ts +++ b/extensions/copilot/src/extension/conversation/vscode-node/conversationFeature.ts @@ -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)); } } diff --git a/extensions/copilot/src/extension/prompts/node/panel/workspace/workspaceContext.tsx b/extensions/copilot/src/extension/prompts/node/panel/workspace/workspaceContext.tsx index d026e6a1657..7040a6f8b9d 100644 --- a/extensions/copilot/src/extension/prompts/node/panel/workspace/workspaceContext.tsx +++ b/extensions/copilot/src/extension/prompts/node/panel/workspace/workspaceContext.tsx @@ -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 | undefined, token = CancellationToken.None): Promise { + 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 | undefined { + if (state.result === undefined) { + return The workspace index is not available at this time.; + } + return { + 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, } };