Skip to content

chat: open session file artifacts through the remote agent host - #343483

Merged
Logan Ramos (lramos15) merged 2 commits into
mainfrom
lramos15/remote-video-artifacts
Oct 22, 2026
Merged

Logan Ramos (lramos15) merged 2 commits into
mainfrom
lramos15/remote-video-artifacts

Conversation

@lramos15

Copy link
Copy Markdown
Member

Fixes #343050

Opening a session's file artifact from the Artifacts pill in a Remote-SSH Editor Window opened the remote path as a local file, so the video preview showed "An error occurred while loading the video file". The renderer logged:

Webview.loadLocalResource - Error using fileReader. requestUri=file:///home/<user>/projects/<project>/videos/walkthrough.mp4?version=...

Cause

In a window attached to a remote, the window's own agent host runs on the remote, but its sessions resolve with the reserved local authority. The artifact pill passed that authority to toAgentHostUri, which deliberately leaves file: URIs unwrapped for local. The pill therefore opened file:///home/... from the client's disk instead of reading the file through the agent host. The same session works in the Agents window because it connects to the remote through a named connection, so its artifact URIs are wrapped.

Fix

File artifacts are now wrapped with the authority the session's connection uses for its own resource URIs (connection.resourceUris). Local windows and remote agent host connections produce the same URIs as before.

How to test

  1. Open a Remote-SSH window with the agent host enabled.
  2. In a chat session, have the agent create a file on the remote (for example an .mp4) and add it as an artifact.
  3. Click the artifact in the Artifacts pill. It now opens in the Video Preview and plays. Before this change, the preview showed the load error above.

Validation

  • ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts: passed (92 tests). The new test covers a local window, a Remote-SSH window, and a remote agent host connection. Without the fix, the Remote-SSH case opens file:///home/user/videos/walkthrough.mp4.
  • npm run typecheck-client: passed.
  • npm run eslint -- <changed files>: passed.
  • Not run: an end-to-end check in a Remote-SSH window with a build containing this change.

Not in this PR

Two more places use the session's local authority in Remote-SSH windows and are left for a follow-up:

  • The Changes pill builds its session diff URIs the same way.
  • AgentHostContribution creates the customization item provider with a hard-coded 'local'.

In a window attached to a remote, the window's own agent host runs on the remote but its sessions resolve with the reserved `local` authority. Artifact pills wrapped file artifacts with that authority, which leaves `file:` URIs unwrapped, so remote files such as generated videos were opened from the client's disk and failed to load. Derive the authority from the connection's resource URI mapping instead.

Fixes #343050

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:25

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Fixes opening session file artifacts from the Artifacts pill in Remote-SSH windows by ensuring the opened URI is wrapped using the session connection’s resource URI mapper (rather than the session’s reserved local authority), so files are read via the remote agent host instead of the client filesystem.

Changes:

  • Derive the correct authority for file-artifact URIs from the connection’s resourceUris mapping and use it when wrapping file: artifacts via toAgentHostUri.
  • Add coverage ensuring file artifacts open through the owning connection across local, remote window (ambient remote), and named remote host scenarios.
File Description
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSessionInputPills.ts Uses connection-derived resource authority when wrapping file artifacts so remote artifacts open through the agent host.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentHost/​agentHostSessionInputPills.test.ts Adds a regression test verifying artifact opening behavior across local/remote authority scenarios.

Review effort: Lite

Clicking a single artifact pill opens its resource synchronously, so the test no longer waits for a macrotask before asserting.

Co-authored-by: Copilot <[email protected]>
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.

Editor Window: No video preview

5 participants