Skip to content

Fix WSL resource links in Agent Host chat responses - #333635

Merged
Dileep Yavanmandha (dileepyavan) merged 5 commits into
mainfrom
DileepY/wsl_markdown_links
Aug 31, 2026
Merged

Fix WSL resource links in Agent Host chat responses#333635
Dileep Yavanmandha (dileepyavan) merged 5 commits into
mainfrom
DileepY/wsl_markdown_links

Conversation

@dileepyavan

Copy link
Copy Markdown
Member

Problem

File links and images in Agent Host chat responses can resolve against the local filesystem instead of the WSL filesystem when a locally identified session is backed by a WSL Agent Host connection.

The response URI resolver used the session handler's connectionAuthority to rewrite resource targets. That authority can remain local even though the active connection's resource URI mapper points to WSL. In that case an absolute Linux path or file: URI stays a local file URI rather than being routed through the owning Agent Host connection.

Reproduction scenario

  1. Use an Agent Host chat session backed by a WSL connection while the session handler has a local authority.
  2. Have the agent return a Markdown file link such as [file](/home/user/project/src/file.ts:42:7) or an image path in the WSL filesystem.
  3. Open the file link or render the image.

Expected: Resolve through the WSL Agent Host connection, retaining the file path and line/column selection.

Actual before this fix: The target is interpreted as a local filesystem resource, so the intended WSL resource may not open or render.

Fix

  • Pass the active connection's resourceUris mapper from AgentHostSessionHandler.resolveChatResponseUri into rewriteAgentHostLinkTarget.
  • Map parsed targets with resourceUris.fromAgentHost rather than constructing their destination from the session authority alone.
  • Keep an authority-based default mapper for existing callers.
  • Add regression coverage for WSL file links with line/column selections, file: URIs, encoded image paths, and preservation of local, external, and already mapped links.

Validation

  • 5 focused tests passed: the response resource links suite in agentHostChatContribution.test.ts and the rewriteAgentHostLinkTarget suite in stateToProgressAdapter.test.ts.
  • No editor diagnostics in the three changed files.
  • git diff origin/main...HEAD --check passed.
./scripts/test.sh \
  --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts \
  --run src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts \
  --grep 'response resource links|rewriteAgentHostLinkTarget'

The WSL scenario is covered by unit regression tests; no end-to-end WSL UI validation was performed for this PR.

Signed-off-by: Dileep Yavanmandha <dileepy@microsoft.com>
Copilot AI balanced review requested due to automatic review settings August 31, 2026 20:42

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.

Copilot review overview

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​stateToProgressAdapter.ts — The local Agent Host uses identityAgentHostResourceUriMapper, so this now returns internal…
What changed in this PR

Routes Agent Host response links through the active connection’s resource URI mapper, fixing WSL-backed resources.

Changes:

  • Use the connection mapper when rewriting links and images.
  • Add WSL and link-preservation regression tests.
File Description
agentHostSessionHandler.ts Passes the active resource mapper.
stateToProgressAdapter.ts Maps parsed response targets.
agentHostChatContribution.test.ts Tests WSL links, images, and preserved targets.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Format default Markdown link hovers with the host-aware label service while preserving navigation targets and custom titles. Add coverage for WSL paths, Windows host formatting, and existing link behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Base: 9a754577 Current: f416a9de

No screenshot changes.

Signed-off-by: Dileep Yavanmandha <dileepy@microsoft.com>
@dileepyavan
Dileep Yavanmandha (dileepyavan) merged commit 735c737 into main Aug 31, 2026
37 checks passed
@dileepyavan
Dileep Yavanmandha (dileepyavan) deleted the DileepY/wsl_markdown_links branch August 31, 2026 23:56
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Aug 31, 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