Fix code search for case where we can't get a local diff#314286
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Copilot's workspace chunk search fallback path so code search can continue when the workspace diff tracker cannot produce a local diff, which is relevant to the external-ingest work tracked in #313281 for non-standard/virtual file systems.
Changes:
- Introduces a
LocalDiffResulttype so local-diff lookup can explicitly returnunknownortooLarge. - Changes workspace search to keep running when no concrete diff file list is available instead of bailing out immediately.
- Adjusts external-ingest/local-result filtering so merge logic can operate with an optional diff pattern.
Show a summary per file
| File | Description |
|---|---|
extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/codeSearchChunkSearch.ts |
Extends local-diff handling and fallback merge behavior in Copilot workspace/code search. |
Copilot's findings
Comments suppressed due to low confidence (2)
extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/codeSearchChunkSearch.ts:715
- This fallback only helps after
searchWorkspace()has already started, butsearchWorkspace()still callsisAvailable()first andisAvailable()still rejects'unknown'/'tooLarge'diffs unless external ingest is enabled. Because external ingest is off by default, the original 'can't get a local diff' failure still reproduces for the normal code-search-only configuration.
if (Array.isArray(diffArray)) {
// Force it to search the local diff too so we can override stale code-search results.
await raceCancellationError(this._externalIngestIndex.value.updateForceIncludeFiles(diffArray, token), token);
}
const externalResult = await this._externalIngestIndex.value.search(sizing, query, innerTelemetryInfo, token);
if (externalResult) {
if (!Array.isArray(diffArray)) {
return { chunks: externalResult, strategyId: 'externalIngest' };
extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/codeSearchChunkSearch.ts:710
- Skipping
updateForceIncludeFiles()for non-array diff states leaves whatever files were force-included by the previous successful diff inExternalIngestIndex. Since this new path later accepts all external-ingest hits whendiffFilePatternis undefined, an old diff snapshot can keep overriding current remote results after the local diff becomes unavailable.
if (Array.isArray(diffArray)) {
// Force it to search the local diff too so we can override stale code-search results.
await raceCancellationError(this._externalIngestIndex.value.updateForceIncludeFiles(diffArray, token), token);
}
- Files reviewed: 1/1 changed files
- Comments generated: 1
| @@ -568,11 +570,7 @@ export class CodeSearchChunkSearch extends Disposable { | |||
| const indexedRepos = allRepos.filter(repo => repo.status === CodeSearchRepoStatus.Ready); | |||
|
|
|||
| const diffArray = await raceCancellationError(this.getLocalDiff(), token); | |||
roblourens
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #313281