Skip to content

Update chat inline references after late anchor resolution#314281

Merged
vijayupadya merged 2 commits into
microsoft:mainfrom
pranavvaid-ac:pranav/symbol-linkifier-fallback
May 9, 2026
Merged

Update chat inline references after late anchor resolution#314281
vijayupadya merged 2 commits into
microsoft:mainfrom
pranavvaid-ac:pranav/symbol-linkifier-fallback

Conversation

@pranavvaid-ac
Copy link
Copy Markdown
Contributor

@pranavvaid-ac pranavvaid-ac commented May 4, 2026

Fixes late-resolved chat inline references so markdown link anchors can update after the extension host resolves richer symbol information, which is an outstanding TODO item.

Changes

  • Add response-model support for resolving an existing inline reference by resolveId.
  • Update main-thread chat anchor resolution to write resolved inline references back into the response model.
  • Ensure markdown parts compare inline-reference metadata, not only markdown text.
  • Prevent incremental markdown rendering from swallowing metadata-only inline-reference updates.
  • Remove the stale TODO for late inline-reference resolution.
  • Add coverage for response-model updates, markdown metadata comparison, workspace-symbol metadata, and incremental-rendering behavior.

Testing

  • npm run compile-check-ts-native
  • npm run test-browser-no-install -- --run src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatMarkdownContentPart.test.ts --grep "inline reference" --browser chromium
  • npm run test-node -- --run src/vs/workbench/contrib/chat/test/common/model/chatModel.test.ts --grep "resolve inline reference"

Part of #313533

Copilot AI review requested due to automatic review settings May 4, 2026 23:24
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

This PR aims to make late-resolved chat anchor metadata propagate through the chat response/rendering pipeline so inline anchors can refresh after richer symbol information arrives. It touches the response model, main-thread agent progress handling, markdown content diffing, and adds regression coverage around those flows.

Changes:

  • Adds response-model support for resolving an existing inline reference by resolveId.
  • Updates main-thread chat agent progress handling to write resolved anchor data back into the response model.
  • Tightens markdown-content equality/incremental-update checks so inline-reference metadata changes can trigger re-rendering, with new tests covering those cases.

Reviewed changes

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

Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/model/chatModel.test.ts Adds response-model tests for resolving inline references.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatMarkdownContentPart.test.ts Adds markdown-part tests for metadata comparisons and incremental rendering behavior.
src/vs/workbench/contrib/chat/common/model/chatModel.ts Adds resolveInlineReference to the response model and implementation.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts Makes markdown equality/incremental updates compare inline-reference metadata.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.ts Removes a stale TODO related to late inline-reference resolution.
src/vs/workbench/api/browser/mainThreadChatAgents2.ts Tracks unresolved anchors and applies resolved anchor data back into chat responses.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts:466

  • Metadata-only inline-reference updates are still treated as unchanged while a streaming edit pill is active. If the markdown text is unchanged but an inline reference resolves to richer symbol metadata, this fallback path returns true based only on the code-block fence position, so the part will skip the re-render that should refresh the anchor widget.
		if (other.content.value === this.markdown.content.value && equalsInlineReferences(other.inlineReferences, this.markdown.inlineReferences)) {
			return true;
		}

		// If we are streaming in code shown in an edit pill, do not re-render the entire content as long as it's coming in
		const lastCodeblock = this._codeblocks.at(-1);
		if (lastCodeblock && lastCodeblock.codemapperUri !== undefined && lastCodeblock.isStreamingEdit) {
			return other.content.value.lastIndexOf('```') === this.markdown.content.value.lastIndexOf('```');

Comment on lines +588 to +595
const unresolvedAnchorsForRequest = this._unresolvedAnchors.get(requestId);
if (!unresolvedAnchorsForRequest) {
return;
}

this._unresolvedAnchors.get(requestId)?.delete(handle);
const unresolvedAnchor = unresolvedAnchorsForRequest.get(handle);
if (!unresolvedAnchor) {
return;
@pranavvaid-ac pranavvaid-ac marked this pull request as ready for review May 5, 2026 00:03
@pranavvaid-ac
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@vijayupadya vijayupadya merged commit 338c5d6 into microsoft:main May 9, 2026
25 of 26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 9, 2026
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.

5 participants