Skip to content

[STACKED] agentHost: correctly rewrite links in markdown for remote files#311041

Merged
connor4312 merged 5 commits intomainfrom
connor4312/ra-links
Apr 17, 2026
Merged

[STACKED] agentHost: correctly rewrite links in markdown for remote files#311041
connor4312 merged 5 commits intomainfrom
connor4312/ra-links

Conversation

@connor4312
Copy link
Copy Markdown
Member

@connor4312 connor4312 commented Apr 17, 2026

Stacked on #311025, but we don't have stacked PRs enabled for vscode yet 😓 . Just review the commit matching the PR title.

Copilot AI review requested due to automatic review settings April 17, 2026 16:32
@connor4312 connor4312 changed the title agentHost: correctly rewrite links in markdown for remote files [STACKED] agentHost: correctly rewrite links in markdown for remote files Apr 17, 2026
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 improves how Agent Host–provided content is represented in the chat UI by (a) rewriting remote-resource markdown links so they resolve through the vscode-agent-host:// filesystem mapping, and (b) enhancing write-permission confirmations to carry richer “before/after” content URIs for diff previews.

Changes:

  • Rewrite markdown link targets in agent-host streamed/history content to vscode-agent-host://<authority>/... while preserving code spans/blocks.
  • Add support for diff previews during write-permission confirmations via a pending-edit-content: in-memory filesystem and new “content URI” fields for modified-files confirmations.
  • Extend chat reference/opening logic to prefer explicit original/modified content URIs when opening diffs.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts Adds coverage for markdown link rewriting (including code fence/codespan exclusions) and updates helpers for new adapter signatures.
src/vs/workbench/contrib/chat/common/chatService/chatService.ts Extends chat reference/modified-files confirmation data to support explicit original/modified content URIs for diff rendering.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatModifiedFilesConfirmationSubPart.ts Uses new content URI fields when opening single diffs and multi-diff views.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Implements markdown link rewriting via marked + toAgentHostUri, threads connectionAuthority through adapters, and maps pending edits into modified-files confirmations.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts Tightens diffs parameter typing to readonly.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Threads connectionAuthority into adapter calls so rewritten URIs can be produced.
src/vs/sessions/common/agentHostDiffs.ts Switches to protocol ISessionFileDiff typing for diff-to-change conversion helpers.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Reduces flakiness by awaiting tool_ready progress explicitly.
src/vs/platform/agentHost/node/copilot/pendingEditContentStore.ts Introduces pending-edit-content: scheme + provider registration helper for transient “after” content.
src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts Adjusts permission display link formatting.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Builds write-permission edit previews by writing “after” content into pending-edit-content: and emitting edits with diff counts.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Updates session config typing to ResumeSessionConfig.
src/vs/platform/agentHost/node/agentHostServerMain.ts Registers the pending-edit-content: in-memory provider.
src/vs/platform/agentHost/node/agentHostMain.ts Registers the pending-edit-content: in-memory provider.
src/vs/platform/agentHost/node/agentEventMapper.ts Maps edits onto the tool-ready action payload.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Bumps protocol version pointer.
src/vs/platform/agentHost/common/agentService.ts Extends IAgentToolReadyEvent to include optional edits preview data.

Copilot's findings

  • Files reviewed: 17/17 changed files
  • Comments generated: 4

Comment on lines +1131 to +1135
@@ -1132,7 +1132,7 @@ export class AgentHostSessionHandler extends Disposable implements IChatSessionC
? tc.invocationMessage
: new MarkdownString(tc.invocationMessage.markdown);
this._reviveTerminalIfNeeded(existing, tc, ctx.backendSession);
updateRunningToolSpecificData(existing, tc);
updateRunningToolSpecificData(existing, tc, this._config.connectionAuthority);
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

In _updateToolCallState, the Running || PendingResultConfirmation branch still constructs new MarkdownString(tc.invocationMessage.markdown) directly. That bypasses the new markdown link rewriting, and for PendingResultConfirmation it’s currently the only place that sets invocationMessage (since updateRunningToolSpecificData returns early unless status is Running). Consider reusing the same markdown-to-IMarkdownString helper that applies rewriteMarkdownLinks (or adjusting updateRunningToolSpecificData to handle PendingResultConfirmation) so remote file:/agenthost-content: links continue to resolve correctly in this state too.

See below for a potential fix:

			const updatedInvocation = toolCallStateToInvocation(tc, undefined, ctx.backendSession, this._config.connectionAuthority);
			existing.invocationMessage = updatedInvocation.invocationMessage;

Copilot uses AI. Check for mistakes.
Comment thread src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

Screenshot Changes

Base: 8dac5997 Current: 86b01e44

Changed (2)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after
editor/inlineCompletions/other/JumpToHint/Dark
Before After
before after

TylerLeonhardt
TylerLeonhardt previously approved these changes Apr 17, 2026
@connor4312 connor4312 dismissed TylerLeonhardt’s stale review April 17, 2026 18:30

The merge-base changed after approval.

roblourens
roblourens previously approved these changes Apr 17, 2026
@connor4312 connor4312 dismissed roblourens’s stale review April 17, 2026 18:55

The merge-base changed after approval.

@connor4312 connor4312 merged commit b4bdfac into main Apr 17, 2026
40 of 41 checks passed
@connor4312 connor4312 deleted the connor4312/ra-links branch April 17, 2026 22:10
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 17, 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.

4 participants