Repository navigation
agentHost: resolve remote Working Set files and track parallel edits - #345031
Merged
Justin Chen (justschen) merged 1 commit intoOct 29, 2026
Merged
Conversation
In a window attached to a remote (WSL, dev container, SSH), the ambient agent host runs on the remote but its sessions resolve with the reserved `local` authority. The session Working Set, the editor review and Keep/Undo matching converted the host's changeset files with that authority, which leaves `file:` URIs unwrapped, so clicking a changed file opened a path on the client's disk (shown with Windows separators on a Windows client) and failed. They now use the authority of the connection's resource URIs, as artifact pills already did. FileEditTracker kept one pending and one completed edit per file path. When a batch of tool calls edited one file in parallel, each start replaced the previous one: only one call's edit was recorded and the other calls' edit leases leaked, so the file stayed marked as being edited for the rest of the session. The Working Set then under-counted the agent's changes, the editor review skipped the file and Undo timed out. Edits are now tracked per tool call, matched by tool input or else in order; an edit that starts while others of the file are pending begins from what the last of them wrote; and every lease is released when its edit is taken or dropped. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrency issues in fileEditTracker can produce incorrect before-snapshots, double-counting changes during overlapping completions or attributing a user’s Undo to a subsequent edit.
2 open issues
What changed in this PR
This PR fixes Agent Host Working Set file resolution in remote windows and tracks multiple edits to the same file. It follows the move to opening Working Set files in regular editors and reuses the resource-authority handling introduced for artifact pills.
Changes:
- Resolve Working Set files, editor review, and Keep/Undo matching through the connection’s resource authority.
- Queue edits per file, pair them by tool input, and release their coordinator leases.
- Add regression coverage for remote-window resolution and batched edits.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts |
Tests remote Working Set resources and Keep/Undo operations. |
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostEditReview.test.ts |
Adds remote-window editor review coverage. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionInputPills.ts |
Uses resource authority for Working Set files and operation matching. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostResponseFileChanges.ts |
Exposes the shared resource-authority helper. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostEditReview.ts |
Resolves review files using resource authority. |
src/vs/platform/agentHost/test/node/fileEditTracker.test.ts |
Tests batched edits and missed-completion cleanup. |
src/vs/platform/agentHost/node/shared/fileEditTracker.ts |
Adds per-file edit queues and snapshot chaining. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Passes tool input into edit tracking hooks. |
src/vs/platform/agentHost/node/claude/claudeFileEditObserver.ts |
Passes tool input into observed edit tracking. |
Review effort: Balanced
Justin Chen (justschen)
marked this pull request as ready for review
October 29, 2026 19:16
Justin Chen (justschen)
enabled auto-merge (squash)
October 29, 2026 19:16
Benjamin Christopher Simmonds (benibenj)
approved these changes
Oct 29, 2026
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: TylerLeonhardtMatched files:
|
Justin Chen (justschen)
deleted the
agents/fix-copilot-path-separator-issue
branch
October 29, 2026 19:18
Ladislau Szomoru (lszomoru)
added a commit
that referenced
this pull request
Nov 6, 2026
…346553) * agentHost: open Working Set files of remote windows as remote files 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]> * agentHost: map turn changes through the owning connection's resource 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]> --------- Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This fixes two problems with the session Working Set ("N files changed" above the chat input) in Copilot harness (Agent Host) sessions.
There is no issue for these reports. #308847 shows a similar symptom for file links in chat responses when connected to a Linux server; this PR does not change that code path.
Remote windows: clicking a changed file opens a path on the client
In a window attached to a remote (WSL, dev container, SSH), the window's own agent host runs on the remote, but its sessions resolve with the reserved
localauthority. The Working Set, the editor review (AgentHostEditReview) and the Keep/Undo matching converted the host's changeset files with that authority.toAgentHostUrileavesfile:URIs unwrapped forlocal, so a container file such asfile:///workspaces/app/src/a.tswas treated as a file on the client: on a Windows client it showed as\workspaces\app\src\a.tsand failed to open. The old diff view worked because it only read snapshot content through the agent host; since #344477, Working Set rows open the file itself.The Working Set diffs, the Keep/Undo matching and the editor review now use the authority of the connection's resource URIs, as artifact pills already did since #343483. That helper moved from
agentHostSessionInputPills.tstoagentHostResponseFileChanges.tsasgetAgentHostResourceAuthority. Local windows and separately connected remote agent hosts are unchanged.Parallel edits of one file: the Working Set under-counts and Keep/Undo disappears
FileEditTrackerkept one pending and one completed edit per file path. A batch of tool calls runs all of itspreToolUsehooks before any of its tools, so when several calls edited the same file, eachtrackEditStartreplaced the previous call's entry:isEditingstayed true until the session ended. The editor review skips a file that is being edited, so it showed no inline diff or Keep/Undo, and the host's discard (Undo) waited 30s and failed with "The agent is still editing".FileEditTrackernow keeps per-file queues of pending and completed edits:trackEditStartandcompleteEdittake the tool input, astakeCompletedEditalready did, so each call finds its own entry; calls without input are paired in order. In the reporting session's logs, the hook arguments and thetool.execution_startarguments were structurally equal for all 22 edit calls.The Copilot hooks and the Claude file-edit observer now pass their tool input; both providers share the tracker. Pairing relies on the edits of one file completing in the order they started, which held for every batch in the logs. Two agents editing the same file at the same moment could still be attributed to the wrong call.
How to test
Remote window (Windows client with WSL or a dev container):
chat.editor.workingSet.enabledtotrueand start a Copilot harness chat.\-separated path on the client.Parallel edits (any window):
chat.editor.workingSet.enabledtotrueand use the Copilot harness with a model that batches tool calls, such as Claude Sonnet 5.5.Validation
./scripts/test.sh --reporter dot --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 --run src/vs/workbench/contrib/chat/test/browser/widget/input/chatSessionWorkingSet.test.ts: passed, 290 passing../scripts/test.sh --reporter dot --runGlob "vs/platform/agentHost/test/node/*.test.js": passed, 12,367 passing and 74 pending.file:///repo/file.tson the client, the editor review never loads the file, and the tracker reportsediting: truewith later calls not recorded.npm run eslint -- <the 9 changed files>: passed.npm run typecheck-client: passed.npm run build-fast(client, built-in extensions and Copilot): passed.editcalls (onepreToolUsebatch of 3). The Working Set showed +3 −3 and the review "3 of 3"; Keep gave "2 of 2", Undo gave "1 of 1" with the file restored, and Keep cleared the rest.localauthority with a remote resource URI mapper).