Skip to content

Add statistics for default diagnostic provider#3232

Merged
dbaeumer merged 3 commits intomainfrom
dbaeumer/initial-opossum-white
Jan 28, 2026
Merged

Add statistics for default diagnostic provider#3232
dbaeumer merged 3 commits intomainfrom
dbaeumer/initial-opossum-white

Conversation

@dbaeumer
Copy link
Member

Enhance the default diagnostic provider by adding statistics tracking and updating related tests to ensure functionality.

Copilot AI review requested due to automatic review settings January 28, 2026 17:21
@dbaeumer dbaeumer enabled auto-merge January 28, 2026 17:21
@dbaeumer dbaeumer self-assigned this Jan 28, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 28, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds statistics tracking for the “default diagnostics” provider so its diagnostic bag is represented in context-provider telemetry, and updates tests to exercise the new API entry point.

Changes:

  • Introduces addDefaultDiagnosticBag(...) to append default diagnostics and record provider statistics/resolution metadata.
  • Updates diagnostics context processing naming and expectation setup helper usage.
  • Updates prompt factory tests to call the new method and use stronger typing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.ts Refactors expectation setup helper for diagnostic bags (but still impacts how expectations are recorded).
src/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.tsx Adds default-diagnostics bag injection plus statistics + resolvedContextItems telemetry wiring.
src/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/test/completionsPromptFactory.test.tsx Updates tests to call addDefaultDiagnosticBag and adjusts types/imports accordingly.

Comment on lines 22 to 25
// Set expectations for the diagnostics provided.
for (const item of diagnosticBags) {
setupExpectationsForDiagnostics(accessor, completionId, item.data, item.providerId);
setupExpectationsForDiagnosticBags(accessor, completionId, item.data, item.providerId);
}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDiagnosticsFromContextItems currently adds expectations twice for the same diagnostic bag: once via setupExpectationsForDiagnosticBags(...) and again inside the validity filter (including potentially adding both included and content_excluded for invalid items). This can lead to duplicated/conflicting expectations and incorrect usage telemetry (e.g. an excluded diagnostic also having an included expectation, which will later be marked as error). Consider removing the upfront setupExpectationsForDiagnosticBags call and only setting expectations in the validity filter (or otherwise ensuring each bag gets exactly one expectation).

Copilot uses AI. Check for mistakes.
Comment on lines +366 to +368
const settings = this.instantiationService.invokeFunction(getDefaultDiagnosticSettings);
diagnosticBags = this.addDefaultDiagnosticBag(resolvedContextItems, diagnosticBags, completionId, completionState, settings);
return { traits, codeSnippets, diagnostics: diagnosticBags, turnOffSimilarFiles, resolvedContextItems };
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveContext calls addDefaultDiagnosticBag(...) unconditionally, but addDefaultDiagnosticBag records expectations/resolution in contextProviderStatistics. If useContextProviderAPI(...) is false, computeMatch(...) is never called, so these expectations are never cleared (they’re only cleared in computeMatch’s finally), which can lead to stale/accumulating expectations and incorrect telemetry on later completions. Consider only recording statistics / pushing into resolvedContextItems when the context provider API is enabled (or ensure expectations are cleared when telemetry won’t be computed).

Copilot uses AI. Check for mistakes.
Comment on lines +931 to +939
type PromptFactoryWithDiagnostic = IPromptFactory & {
addDefaultDiagnosticBag(
resolvedContextItems: ResolvedContextItem[],
bags: DiagnosticBagWithId[] | undefined,
completionId: string,
completionState: CompletionState,
settings: DefaultDiagnosticSettings
): DiagnosticBagWithId[] | undefined;
};
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addDefaultDiagnosticBag now mutates resolvedContextItems and adds expectations/lastResolution for provider statistics, but the updated tests only validate the returned diagnostic bags. Consider adding coverage that asserts (1) resolvedContextItems gets an entry for copilot.chat.defaultDiagnostics with expected resolution/matchScore, and (2) provider statistics were updated (e.g. by overriding ICompletionsContextProviderService in the test context to use TestContextProviderStatistics so expectations/lastResolution can be inspected).

Copilot uses AI. Check for mistakes.
@dbaeumer dbaeumer added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit 35e9c5b Jan 28, 2026
25 checks passed
@dbaeumer dbaeumer deleted the dbaeumer/initial-opossum-white branch January 28, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants