Report the request UUID under the Opportunity ID line

Instead of adding a dedicated "Request UUID" line, populate the existing
"Opportunity ID" diagnostic from the shown item's `opportunityId` (VS Code
core's `InlineCompletionContext.requestUuid`).

Drop the now-redundant telemetry-sourced "Opportunity ID" assignment: the
item value is authoritative and avoids a potentially stale
`telemetry.properties.opportunityId` for cached / typing-as-suggested
completions. Update the tests accordingly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
ulugbekna
2026-07-06 21:01:31 +02:00
parent ae0d0cf957
commit d4affdc2d2
2 changed files with 10 additions and 14 deletions
@@ -23,13 +23,13 @@ interface Section {
items: SectionItems;
}
export function collectCompletionDiagnostics(accessor: ServicesAccessor, telemetry: TelemetryData | undefined, requestUuid?: string): Report {
export function collectCompletionDiagnostics(accessor: ServicesAccessor, telemetry: TelemetryData | undefined, opportunityId?: string): Report {
const telemetryItems: SectionItems = {};
// The request UUID (VS Code core's `InlineCompletionContext.requestUuid`) is sourced from the shown
// The opportunity ID (VS Code core's `InlineCompletionContext.requestUuid`) is sourced from the shown
// item rather than `telemetry.properties.opportunityId`, since the latter can be stale for cached or
// typing-as-suggested completions whose telemetry is derived from an earlier request.
if (requestUuid) {
telemetryItems['Request UUID'] = requestUuid;
if (opportunityId) {
telemetryItems['Opportunity ID'] = opportunityId;
}
if (telemetry !== undefined) {
if (telemetry.properties.headerRequestId) {
@@ -38,9 +38,6 @@ export function collectCompletionDiagnostics(accessor: ServicesAccessor, telemet
if (telemetry.properties.choiceIndex) {
telemetryItems['Choice Index'] = telemetry.properties.choiceIndex;
}
if (telemetry.properties.opportunityId) {
telemetryItems['Opportunity ID'] = telemetry.properties.opportunityId;
}
if (telemetry.properties.clientCompletionId) {
telemetryItems['Client Completion ID'] = telemetry.properties.clientCompletionId;
}
@@ -17,11 +17,11 @@ suite('collectCompletionDiagnostics', function () {
accessor = createLibTestingContext().createTestingAccessor();
});
test('includes the request UUID alongside the telemetry fields', function () {
test('includes the opportunity ID alongside the telemetry fields', function () {
const telemetry = TelemetryWithExp.createEmptyConfigForTesting();
telemetry.properties.headerRequestId = 'header-123';
telemetry.properties.choiceIndex = '0';
// A different value than the passed request UUID to prove the two are sourced independently.
// A stale value that must be ignored: the opportunity ID comes from the item, not from telemetry.
telemetry.properties.opportunityId = 'stale-opportunity-id';
telemetry.properties.clientCompletionId = 'client-abc';
telemetry.properties.engineName = 'test-model';
@@ -34,19 +34,18 @@ suite('collectCompletionDiagnostics', function () {
items: {
Version: BuildInfo.getVersion(),
Editor: 'lib-tests-editor 1',
'Request UUID': 'icr-current-uuid',
'Opportunity ID': 'icr-current-uuid',
'Header Request ID': 'header-123',
'Choice Index': '0',
'Opportunity ID': 'stale-opportunity-id',
'Client Completion ID': 'client-abc',
'Model ID': 'test-model',
},
},
]);
assert.ok(formatDiagnosticsAsMarkdown(report).includes('- Request UUID: icr-current-uuid'));
assert.ok(formatDiagnosticsAsMarkdown(report).includes('- Opportunity ID: icr-current-uuid'));
});
test('includes the request UUID even when no telemetry is available', function () {
test('includes the opportunity ID even when no telemetry is available', function () {
const report = collectCompletionDiagnostics(accessor, undefined, 'icr-only');
assert.deepStrictEqual(report.sections, [
@@ -55,7 +54,7 @@ suite('collectCompletionDiagnostics', function () {
items: {
Version: BuildInfo.getVersion(),
Editor: 'lib-tests-editor 1',
'Request UUID': 'icr-only',
'Opportunity ID': 'icr-only',
},
},
]);