Skip to content

Fix handleEndOfLifetime supersededBy tracking for inline completions#320143

Merged
ulugbekna merged 1 commit into
microsoft:mainfrom
yavanosta:inline-completion-end-of-life-pid-fix
Jun 23, 2026
Merged

Fix handleEndOfLifetime supersededBy tracking for inline completions#320143
ulugbekna merged 1 commit into
microsoft:mainfrom
yavanosta:inline-completion-end-of-life-pid-fix

Conversation

@yavanosta

Copy link
Copy Markdown
Contributor

Problem

When an inline completion item is superseded by a newer suggestion (e.g., from a subsequent completion request), the extension host provider's handleEndOfLifetime callback should receive the superseding completion item via reason.supersededBy. Instead, providers were receiving the old completion item itself (essentially being told the item superseded itself).

Root Cause

When the main thread processes handleEndOfLifetime in mainThreadLanguageFeatures.ts, it maps reason.supersededBy into an IPC reference { pid, idx }. Because individual IdentifiableInlineCompletion items only tracked idx and not pid, mapReason incorrectly fell back to using completions.pid:

mapReason(reason, i => ({ pid: completions.pid, idx: i.idx }))

Since completions.pid refers to the old completion list being disposed, it paired the old list's PID with the new item's index (0). When this arrived at the extension host, it resolved this._references.get(oldPid)?.items[0], incorrectly fetching the old item instead of the new one.

Solution

  1. Protocol Definition: Added pid: number to the IdentifiableInlineCompletion DTO interface in extHost.protocol.ts.
  2. Extension Host: Updated InlineCompletionAdapter.provideInlineCompletions in extHostLanguageFeatures.ts to include pid on every completion item DTO sent across the IPC bridge.
  3. Main Thread: Updated mapReason in mainThreadLanguageFeatures.ts to use i.pid instead of completions.pid.

Impact

This change is entirely scoped to the internal Core <-> Extension Host RPC boundary. The public vscode extension API remains 100% unchanged.

Copilot AI review requested due to automatic review settings June 5, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds per-item pid tracking to inline completion items so end-of-lifetime events can reference the originating provider/id more precisely.

Changes:

  • Add pid to IdentifiableInlineCompletion to identify the originating provider/id per item.
  • Populate pid when converting inline completion items on the extension host side.
  • Update end-of-lifetime event mapping to forward pid from each reason item.

Reviewed changes

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

File Description
src/vs/workbench/api/common/extHostLanguageFeatures.ts Includes pid on marshalled inline completion items sent to main thread.
src/vs/workbench/api/common/extHost.protocol.ts Extends the cross-thread inline completion item shape with pid.
src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts Adjusts end-of-lifetime event mapping to use per-item pid values.
Comment thread src/vs/workbench/api/common/extHost.protocol.ts
Comment thread src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts
Comment thread src/vs/workbench/api/common/extHost.protocol.ts

@hediet hediet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@hediet hediet enabled auto-merge (rebase) June 22, 2026 15:36
@ulugbekna ulugbekna closed this Jun 22, 2026
auto-merge was automatically disabled June 22, 2026 15:54

Pull request was closed

@ulugbekna ulugbekna reopened this Jun 22, 2026
@ulugbekna ulugbekna enabled auto-merge (squash) June 22, 2026 19:35
@ulugbekna ulugbekna force-pushed the inline-completion-end-of-life-pid-fix branch from e5c5d17 to b35d8dc Compare June 23, 2026 07:28
@ulugbekna ulugbekna merged commit 9ad71eb into microsoft:main Jun 23, 2026
28 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

8 participants