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, } };