Copilot: track shown ghost text suggestions to filter redundant re-display#309497
Draft
Copilot: track shown ghost text suggestions to filter redundant re-display#309497
Conversation
…splay Add ShownGhostTextTracker to track NES ghost text suggestions that were shown to the user, gated behind the InlineEditsGhostTextTracking team-internal config flag. Behavior: - Rejected suggestions (explicit Escape) are never shown again - Ignored suggestions are only re-shown if the cursor is at the same position and document contents haven't changed - Accepted suggestions clear their tracking entry Includes 15 unit tests and handles the race condition where provideInlineCompletionItems fires before handleEndOfLifetime of the previously shown ghost text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Adds internal ghost-text tracking to the Copilot inline edits flow to avoid repeatedly re-displaying the same NES ghost text suggestion, gated behind a new team-internal configuration flag.
Changes:
- Introduces
ShownGhostTextTracker(pluscomputeGhostTextEditKey) to track rejected/ignored/accepted ghost text suggestions per document. - Integrates filtering + outcome recording into
InlineCompletionProviderImpl, including race handling for show/end-of-lifetime ordering. - Adds a team-internal config flag
chat.advanced.inlineEdits.ghostTextTrackingand unit tests for the tracker.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/configuration/common/configurationService.ts | Adds the team-internal flag to gate ghost text tracking. |
| extensions/copilot/src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts | Filters previously shown ghost text and records outcomes (ignored/rejected/accepted) during item lifecycle. |
| extensions/copilot/src/extension/inlineEdits/common/shownGhostTextTracker.ts | Implements the in-memory tracking logic keyed by document + edit identity. |
| extensions/copilot/src/extension/inlineEdits/test/common/shownGhostTextTracker.spec.ts | Adds unit tests covering tracker behavior and key determinism. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
extensions/copilot/src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts
Outdated
Show resolved
Hide resolved
extensions/copilot/src/extension/inlineEdits/common/shownGhostTextTracker.ts
Show resolved
Hide resolved
…ose cleanup - Use targetDocument.uri for ghost text tracking identity instead of the requesting document, correctly handling cross-file completions - Add clearDocument() to remove all tracking when a document is closed - Add per-document size cap (200 entries) with oldest-half eviction - Register workspace.onDidCloseTextDocument to call clearDocument() - Add 3 new tests for clearDocument and eviction behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Adds
ShownGhostTextTrackerto the Copilot extension to track NES ghost text suggestions that were shown to the user and filter redundant re-display. Gated behind theInlineEditsGhostTextTrackingteam-internal config flag (default:false).Behavior
Implementation
New files
extensions/copilot/src/extension/inlineEdits/common/shownGhostTextTracker.ts— Pure-logic tracker class withrecordRejected(),recordIgnored(),shouldFilter(), andclearTracking(). UsescomputeGhostTextEditKey()(range + insertText) for identity.extensions/copilot/src/extension/inlineEdits/test/common/shownGhostTextTracker.spec.ts— 15 unit tests covering all tracker behaviorsModified files
extensions/copilot/src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts— Integration intoInlineCompletionProviderImpl:_provideInlineCompletionItems()viashouldFilter()NesCompletionItemfor GC-friendly trackinghandleDidShowCompletionItem()handleEndOfLifetime()via_recordGhostTextOutcome()_pendingShownGhostTextfor cases whereprovideInlineCompletionItems()fires beforehandleEndOfLifetime()of the previous ghost textextensions/copilot/src/platform/configuration/common/configurationService.ts— AddedInlineEditsGhostTextTrackingteam-internal boolean flagTesting