Skip to content

Copilot: track shown ghost text suggestions to filter redundant re-display#309497

Draft
ulugbekna wants to merge 3 commits intomainfrom
ulugbekna/agents/alleged-canid
Draft

Copilot: track shown ghost text suggestions to filter redundant re-display#309497
ulugbekna wants to merge 3 commits intomainfrom
ulugbekna/agents/alleged-canid

Conversation

@ulugbekna
Copy link
Copy Markdown
Contributor

Summary

Adds ShownGhostTextTracker to the Copilot extension to track NES ghost text suggestions that were shown to the user and filter redundant re-display. Gated behind the InlineEditsGhostTextTracking team-internal config flag (default: false).

Behavior

  • Rejected (explicit Escape): The suggestion is never shown again for that document
  • Ignored (cursor moved away, blur, etc.): The suggestion is only re-shown if it would still be ghost text (not an inline edit), the cursor is at the same position, and document contents haven't changed
  • Accepted: Clears the tracking entry so the suggestion can appear again naturally

Implementation

New files

  • extensions/copilot/src/extension/inlineEdits/common/shownGhostTextTracker.ts — Pure-logic tracker class with recordRejected(), recordIgnored(), shouldFilter(), and clearTracking(). Uses computeGhostTextEditKey() (range + insertText) for identity.
  • extensions/copilot/src/extension/inlineEdits/test/common/shownGhostTextTracker.spec.ts — 15 unit tests covering all tracker behaviors

Modified files

  • extensions/copilot/src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts — Integration into InlineCompletionProviderImpl:
    • Filtering in _provideInlineCompletionItems() via shouldFilter()
    • Context stored via WeakMap on NesCompletionItem for GC-friendly tracking
    • Show tracking in handleDidShowCompletionItem()
    • Outcome recording in handleEndOfLifetime() via _recordGhostTextOutcome()
    • Race condition handling with _pendingShownGhostText for cases where provideInlineCompletionItems() fires before handleEndOfLifetime() of the previous ghost text
  • extensions/copilot/src/platform/configuration/common/configurationService.ts — Added InlineEditsGhostTextTracking team-internal boolean flag

Testing

  • 15 vitest unit tests all passing
  • TypeScript compilation clean for both copilot extension and main VS Code
  • Pre-commit hooks (tsfmt + eslint) pass

…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>
Copilot AI review requested due to automatic review settings April 13, 2026 15:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Screenshot Changes

Base: c1f6b9dd Current: 57b50b4f

Changed (1)

editor/inlineCompletions/other/JumpToHint/Dark
Before After
before after

Copy link
Copy Markdown
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 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 (plus computeGhostTextEditKey) 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.ghostTextTracking and 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

ulugbekna and others added 2 commits April 13, 2026 18:46
…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>
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