chat: support inline attachment references#326666
Merged
Merged
Conversation
- Lets users mention context that is already attached so prompts can express where a file, folder, image, pasted text, or other attachment is relevant without duplicating or removing it. - Keeps inline reference state lightweight so large attachment payloads do not cause typing lag, while preserving the original payload when the request is sent. - Prioritizes attached context in # and @ suggestions so existing context is easy to discover and reference. - Adds accessibility guidance and regression coverage for ordering, payload preservation, request ranges, and compact reference state. (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds inline references to existing chat attachments while preserving payloads and minimizing typing-state overhead.
Changes:
- Adds compact attachment-reference state and request-range restoration.
- Prioritizes attached context in
#and@completions. - Adds accessibility guidance and regression tests.
Show a summary per file
| File | Description |
|---|---|
chatRequestParser.test.ts |
Tests payload and range preservation. |
chatVariableEntries.test.ts |
Tests immutable variable replacement. |
chatInputCompletions.test.ts |
Tests completion ranking and filtering. |
chatVariables.test.ts |
Tests compact references and request reconstruction. |
chatRequestParser.ts |
Passes attachment metadata into parsed parts. |
chatParserTypes.ts |
Reconstructs full attachment entries. |
common/attachments/chatVariables.ts |
Defines compact attachment conversions. |
chatVariableEntries.ts |
Adds variable replacement helpers. |
chatInputCompletionUtils.ts |
Adds attachment completion utilities. |
chatInputCompletions.ts |
Provides prioritized attachment suggestions. |
chatWidget.ts |
Preserves attachments while applying prompt ranges. |
browser/attachments/chatVariables.ts |
Detects and applies existing references. |
chatDynamicVariables.ts |
Compacts references to attached context. |
chatAccessibilityHelp.ts |
Documents inline attachment references. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 2
- Review effort level: Medium
justschen
marked this pull request as ready for review
July 21, 2026 23:08
justschen
enabled auto-merge (squash)
July 21, 2026 23:08
justschen
disabled auto-merge
July 21, 2026 23:09
zhichli
previously approved these changes
Jul 21, 2026
Contributor
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables.ts:260
- The lifetime check occurs before another
await. If the attachment is removed/replaced or this contribution is disposed whilethumbnail.arrayBuffer()resolves, the continuation repopulates the cleared hover cache and callsupdateDecorations()on a disposed editor. Perform the attachment/disposal check after the final await.
const thumbnail = await getOrCreateImageThumbnail(attachment.id, buffer, CHAT_IMAGE_HOVER_THUMBNAIL_MAX_SIZE);
if (!thumbnail || !this.widget.input.attachmentModel.attachments.includes(attachment)) {
return;
- Files reviewed: 15/15 changed files
- Comments generated: 1
- Review effort level: Medium
dmitrivMS
previously approved these changes
Jul 22, 2026
justschen
enabled auto-merge (squash)
July 22, 2026 03:17
dmitrivMS
approved these changes
Jul 22, 2026
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.
(Commit message generated by Copilot)