Skip to content

Preserve image source provenance across chat reference API boundary - #320624

Merged
Federico Brancasi (federicobrancasi) merged 4 commits into
microsoft:mainfrom
merfanian:me/chat-image-source-telemetry
Jun 10, 2026
Merged

Federico Brancasi (federicobrancasi) merged 4 commits into
microsoft:mainfrom
merfanian:me/chat-image-source-telemetry

Conversation

@merfanian

Copy link
Copy Markdown
Member

Image attachments lost their source provenance (clipboard, screenshot, file, url) when converted to the ChatPromptReference API type, because ChatReferenceBinaryData did not carry the isPasted/isURL flags. This caused image-source telemetry to collapse to only 'url' and 'unknown'.

Add optional isPasted/isURL to ChatReferenceBinaryData and populate them in the ChatPromptReference.to converter so consumers can recover the original image source.

Image attachments lost their source provenance (clipboard, screenshot, file, url) when converted to the ChatPromptReference API type, because ChatReferenceBinaryData did not carry the isPasted/isURL flags. This caused image-source telemetry to collapse to only 'url' and 'unknown'.

Add optional isPasted/isURL to ChatReferenceBinaryData and populate them in the ChatPromptReference.to converter so consumers can recover the original image source.
Copilot AI review requested due to automatic review settings June 9, 2026 16:17

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 origin metadata to ChatReferenceBinaryData so image variables can indicate whether they were pasted or attached from a URL.

Changes:

  • Extend the proposed vscode.ChatReferenceBinaryData API with isPasted and isURL.
  • Add corresponding fields to the ext host implementation type.
  • Populate the new fields when converting image-variable entries to ChatReferenceBinaryData.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/vscode-dts/vscode.proposed.chatReferenceBinaryData.d.ts Adds new proposed API properties describing image origin.
src/vs/workbench/api/common/extHostTypes.ts Extends ext host ChatReferenceBinaryData shape to carry the new fields.
src/vs/workbench/api/common/extHostTypeConverters.ts Sets the new properties during image variable conversion.

Comment on lines +3558 to +3565
const binaryData = new types.ChatReferenceBinaryData(
variable.mimeType ?? 'image/png',
() => Promise.resolve(new Uint8Array(Object.values(variable.value as number[]))),
ref && URI.isUri(ref) ? ref : undefined
);
binaryData.isPasted = variable.isPasted;
binaryData.isURL = variable.isURL;
value = binaryData;
Address review feedback: set isPasted/isURL as constructor parameters instead of post-construction mutation, following the existing optional 'reference' parameter pattern. This avoids call sites forgetting to set them and eases future moves toward immutability.
@merfanian

Copy link
Copy Markdown
Member Author

@federicobrancasi
Federico Brancasi (federicobrancasi) merged commit 2165dcd into microsoft:main Jun 10, 2026
26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.125.0 milestone Jun 10, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants