Skip to content

Commit f83e7c2

Browse files
authored
NES: use git-merge icon for reused in-flight requests (#311099)
Previously both cache hits and reused in-flight requests (async pending or speculative) showed the database icon in the NES debug log. This made it hard to tell whether a result was served from cache or joined an existing stream. Add a new \`reusedInFlight\` outcome with a git-merge icon ($(git-merge)) to visually distinguish 'joined an in-flight request' from 'loaded from cache'. The database icon is preserved for true cache hits via \`setIsCachedResult\`; reused in-flight requests now go through the new \`setIsReusedInFlightResult\` method.
1 parent 840a3be commit f83e7c2

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

extensions/copilot/src/extension/inlineEdits/node/nextEditProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ export class NextEditProvider extends Disposable implements INextEditProvider<Ne
670670

671671
telemetryBuilder.setRequest(nextEditRequest);
672672
logContext.setRequestInput(nextEditRequest);
673-
logContext.setIsCachedResult(nextEditRequest.logContext);
673+
logContext.setIsReusedInFlightResult(nextEditRequest.logContext);
674674

675675
const disp = this._hookupCancellation(nextEditRequest, cancellationToken);
676676
try {

extensions/copilot/src/platform/inlineEdits/common/inlineEditLogContext.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface MarkdownLoggable {
3737
* - `errored`: an error occurred
3838
* - `previouslyRejected`: result matches a suggestion that was previously rejected
3939
*/
40-
type LogContextOutcome = 'pending' | 'succeeded' | 'noSuggestions' | 'cached' | 'cachedFromGhostText' | 'skipped' | 'cancelled' | 'errored' | 'previouslyRejected';
40+
type LogContextOutcome = 'pending' | 'succeeded' | 'noSuggestions' | 'cached' | 'cachedFromGhostText' | 'reusedInFlight' | 'skipped' | 'cancelled' | 'errored' | 'previouslyRejected';
4141

4242
export class InlineEditRequestLogContext {
4343

@@ -95,6 +95,7 @@ export class InlineEditRequestLogContext {
9595
lines.push(`- ${Icon.lightbulbFull.svg} - model had suggestions\n`);
9696
lines.push(`- ${Icon.circleSlash.svg} - model had NO suggestions\n`);
9797
lines.push(`- ${Icon.database.svg} - response is from cache\n`);
98+
lines.push(`- ${Icon.gitMerge.svg} - joined an in-flight request (async or speculative reuse)\n`);
9899
lines.push(`- ${Icon.error.svg} - error happened\n`);
99100
lines.push(`- ${Icon.skipped.svg} - fetching started but got cancelled\n`);
100101
lines.push('</details>\n');
@@ -312,6 +313,35 @@ export class InlineEditRequestLogContext {
312313
this.fireDidChange();
313314
}
314315

316+
/**
317+
* Marks this log context as having joined an already in-flight request
318+
* (async pending or speculative). The icon shows git-merge to distinguish
319+
* from a true cache hit.
320+
*/
321+
setIsReusedInFlightResult(logContextOfReusedRequest: InlineEditRequestLogContext): void {
322+
this._logContextOfCachedEdit = logContextOfReusedRequest;
323+
324+
this.recordingBookmark = logContextOfReusedRequest.recordingBookmark;
325+
this._nextEditRequest = logContextOfReusedRequest._nextEditRequest ?? this._nextEditRequest;
326+
this._resultEdit = logContextOfReusedRequest._resultEdit ?? this._resultEdit;
327+
this._diagnosticsResultEdit = logContextOfReusedRequest._diagnosticsResultEdit ?? this._diagnosticsResultEdit;
328+
this._endpointInfo = logContextOfReusedRequest._endpointInfo ?? this._endpointInfo;
329+
this._headerRequestId = logContextOfReusedRequest._headerRequestId ?? this._headerRequestId;
330+
if (logContextOfReusedRequest._prompt) {
331+
this._prompt = logContextOfReusedRequest._prompt;
332+
}
333+
this.response = logContextOfReusedRequest.response ?? this.response;
334+
this._responseResults = logContextOfReusedRequest._responseResults ?? this._responseResults;
335+
if (logContextOfReusedRequest.fullResponsePromise) {
336+
this.setFullResponse(logContextOfReusedRequest.fullResponsePromise);
337+
}
338+
this._error = logContextOfReusedRequest._error ?? this._error;
339+
340+
this._isVisible = true;
341+
this._outcome = 'reusedInFlight';
342+
this.fireDidChange();
343+
}
344+
315345
private _endpointInfo: { url: string; modelName: string } | undefined;
316346

317347
public setEndpointInfo(url: string, modelName: string): void {
@@ -375,6 +405,7 @@ export class InlineEditRequestLogContext {
375405
case 'noSuggestions': return Icon.circleSlash;
376406
case 'cached':
377407
case 'cachedFromGhostText': return Icon.database;
408+
case 'reusedInFlight': return Icon.gitMerge;
378409
case 'skipped':
379410
case 'cancelled': return Icon.skipped;
380411
case 'errored': return Icon.error;

extensions/copilot/src/platform/inlineEdits/common/utils/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export namespace Icon {
5454
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" d="M13 3.5C13 2.119 10.761 1 8 1S3 2.119 3 3.5c0 .04.02.077.024.117H3v8.872l.056.357C3.336 14.056 5.429 15 8 15s4.664-.944 4.944-2.154l.056-.357V3.617h-.024c.004-.04.024-.077.024-.117M8 2.032c2.442 0 4 .964 4 1.468s-1.558 1.468-4 1.468S4 4 4 3.5s1.558-1.468 4-1.468m4 10.458l-.03.131C11.855 13.116 10.431 14 8 14s-3.855-.884-3.97-1.379L4 12.49v-7.5A7.4 7.4 0 0 0 8 6a7.4 7.4 0 0 0 4-1.014z"/></svg>`,
5555
};
5656

57+
export const gitMerge: t = {
58+
themeIcon: ThemeIcon.fromId('git-merge'),
59+
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M5 3.254V3.25v.005zm0-.004a1.25 1.25 0 1 0-2.5 0a1.25 1.25 0 0 0 2.5 0m8.001 9.5a1.25 1.25 0 1 0-2.5 0a1.25 1.25 0 0 0 2.5 0M11.5 12a.75.75 0 1 1 1.502 0a.75.75 0 0 1-1.502 0M3.75 2a1.25 1.25 0 0 0-.25 2.474V9.07A3.997 3.997 0 0 0 7.5 12.98v.046a1.25 1.25 0 1 0 1 0v-.046a3.997 3.997 0 0 0 3-3.473V7.5A2.5 2.5 0 0 0 9 5H7a2.5 2.5 0 0 0-2.5 2.5v2.026A2.997 2.997 0 0 1 2.5 7V4.474A1.25 1.25 0 0 0 3.75 2" clip-rule="evenodd"/></svg>`,
60+
};
61+
5762
export const loading: t = {
5863
themeIcon: ThemeIcon.fromId('loading~spin'),
5964
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M13.917 7A6.002 6.002 0 0 0 2.083 7H1.071a7.002 7.002 0 0 1 13.858 0zm0 2a6.002 6.002 0 0 1-11.834 0H1.071a7.002 7.002 0 0 0 13.858 0z" clip-rule="evenodd"/></svg>`,

0 commit comments

Comments
 (0)