Skip to content

agentHost: open Working Set files of remote windows as remote files - #346553

Merged
Ladislau Szomoru (lszomoru) merged 2 commits into
mainfrom
lszomoru/agents/vscode-issue-345420-investigation
Nov 6, 2026
Merged

Ladislau Szomoru (lszomoru) merged 2 commits into
mainfrom
lszomoru/agents/vscode-issue-345420-investigation

Conversation

@lszomoru

@lszomoru Ladislau Szomoru (lszomoru) commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #345420

In a window attached to a remote (WSL, SSH, containers), clicking a file in the Working Set above the chat input fails with "The editor could not be opened because the file was not found." On a Windows client, the path in the error has backslashes (\home\…). View All Edits still works.

Cause

In a remote window, the ambient agent host runs on the remote, but its sessions resolve with the local authority. The Working Set, its Keep/Undo matching, and the editor review converted changeset files with toAgentHostUri(file, authority). For local, that leaves file: URIs unwrapped, so the client opened the remote path on its own disk. View All Edits reads the recorded contents through the host, so it was unaffected.

#345031 fixed this by using the authority of the connection's resource URIs. #345306 then changed the editor-remote mapper to return vscode-remote URIs, so getAgentHostResourceAuthority fell back to local again. The test added in #345031 still used the earlier mapper, so it did not catch the regression.

Change

  • agentHostChangesetFileToEntryDiff takes the owning connection and maps the file with its resourceUris.fromAgentHost, as the Agent Host URI-space guidance asks. In a remote window the file is now the workspace's vscode-remote file. Recorded contents stay Agent Host content URIs and are read through the host as before.
  • The Working Set, its Keep/Undo matching, and the editor review pass their connection, so they still match files by the same URIs.
  • The per-response changes provider maps changeset and response-part files through its connection's resourceUris too, which removes its TODO(agent-host-uri) bypasses. Its outside-workspace check still compares host files with host working directories.
  • The remote-window tests for the Working Set and the editor review now use the real createEditorRemoteAgentHostResourceUriMapper, and the per-response provider tests run across every connection kind in agentHostConnectionKinds. All of them fail without the fix.

Not in this PR

Checkpoint restore in AgentHostSnapshotController still builds file URIs from the authority (TODO(agent-host-uri)), so it has the same problem in a remote window.

How to test

  1. Run ./scripts/code.sh, then Remote-TestResolver: New TestResolver Window, and open a git repository.
  2. Start a new chat with the Copilot harness (chat.editor.preferCopilotHarness and chat.editor.workingSet.enabled are on by default) and ask for an edit.
  3. Expand the Working Set above the chat input and click the file.
  • Before: the file opens as a local file: resource. The breadcrumbs show the absolute path, File: Copy Relative Path of Active File copies an absolute path, and opening the file from the Explorer opens a second tab. A Windows client attached to WSL shows "file not found" instead.
  • After: the file opens as the workspace's file. The breadcrumbs are workspace-relative, and the Explorer reveals the same tab. View All Edits and Keep/Undo keep working.

Validation

  • ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostEditReview.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostResponseFileChanges.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSnapshotController.test.ts: passed (251 tests). Without the fix, the remote-window and connection-kind cases fail.
  • pnpm run typecheck-client: passed
  • pnpm run eslint <changed files>: passed
  • Not yet validated manually in a TestResolver window.

In a window attached to a remote (WSL, SSH, containers), the ambient agent host resolves with the `local` authority. The Working Set, its Keep/Undo matching, and the editor review converted changeset files with `toAgentHostUri(file, authority)`, which leaves `local` file URIs unwrapped. Clicking a changed file then opened the remote path on the client's disk, which a Windows client shows with backslashes and reports as not found.

#345031 fixed this through the connection's mapper authority, but #345306 changed the editor-remote mapper to return `vscode-remote` URIs, so the authority fell back to `local` again. Map the file through the owning connection's `resourceUris.fromAgentHost` instead, so it opens as the workspace's file, while recorded contents stay Agent Host content URIs. The tests now use the real editor-remote mapper.

Fixes #345420

Co-authored-by: Copilot <[email protected]>

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.

🟢 Approval recommended

No active review issues are recorded for the connection-aware Working Set URI mapping changes.

No open issues 🎉

What changed in this PR

Fixes #345420 by mapping Agent Host Working Set files through the owning connection’s URI mapper. In remote windows, files now open as workspace resources rather than paths on the client’s disk.

Changes:

  • Uses the connection’s mapper for Working Set files, Keep/Undo matching, and editor review.
  • Preserves host-backed recorded content and existing per-response changes behavior.
  • Updates remote-window regression tests to use the real editor-remote mapper and adapts other tests to the new helper signature.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentHost/​agentHostSnapshotController.test.ts Passes the identity mapper to the updated helper.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentHost/​agentHostSessionInputPills.test.ts Verifies remote Working Set resources with the real mapper.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentHost/​agentHostResponseFileChanges.test.ts Adapts changeset conversion coverage to the mapper parameter.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentHost/​agentHostEditReview.test.ts Covers editor review with local, remote-host, and editor-remote mappers.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSessionInputPills.ts Supplies the owning mapper for Working Set display and Keep/Undo matching.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostResponseFileChanges.ts Maps file identities through the supplied mapper while preserving recorded-content routing.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostEditReview.ts Uses the Working Set connection’s mapper for review file identities.

Review effort: Balanced

@g561877g-bot

This comment was marked as off-topic.

…URIs

Address review feedback: the changeset helper now takes the owning connection, so callers can no longer pass a mapper built from an authority. The per-response changes provider uses its connection's resourceUris for both changeset and response-part files, which removes its remaining TODO(agent-host-uri) bypasses. Recorded contents stay Agent Host content URIs.

The provider tests now run across every Agent Host connection kind, including the strict exactly-once mapper.

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.

Incorrect path separators in Copilot Chat file links

5 participants