microsoft / microsoft/vscode

Changed-files card incorrectly attributed to wrong chat session when multiple agents share a workspace

Open
#333,633 0 comments 0 reactions 1 assignee Claimed by @roblourens View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

## Description
A file-change card (showing "N files changed +A -D" with `Keep` and `Undo` actions) can appear in a Copilot Chat session even when that session did not perform the edit. This occurs when multiple agent sessions or concurrent chats share the same Git worktree.

## Steps to reproduce
1. Open two separate Copilot Chat sessions in the same VS Code window.
2. Have Agent A make file edits (without committing them).
3. Keep Agent B active without performing any edits.
4. Verify whether Agent B's chat view displays a file-change card for the file that Agent A modified.

## Expected behavior
- File-change cards should only appear in the chat session that requested or performed the edit.
- If a file change occurs outside the current chat's request context, the UI should either:
- Show a neutral indicator such as "Workspace changed outside this chat", or
- Not display a `Keep` / `Undo` action tied to the current session's response.

## Actual behavior
- The file-change card appears in Agent B's chat with `Keep` and `Undo` actions as if Agent B created it.
- This implies that Agent B can review, approve, or undo work it did not author.
- This is unsafe because it encourages ownership claims and potential accidental reversions of another agent's work.

## Environment
- VS Code: 1.135.0
- OS: Windows 11 (10.0.26200)
- Copilot Chat extension: Integrated in VS Code 1.135.0
- Multiple concurrent chat sessions: Yes
- Shared worktree (not isolated): Yes

## Additional context
The public VS Code API (`WorkspaceEdit`, `FileChangeEvent`, `ChatResponseTurn`) does not expose a session ID or edit-transaction ID that would allow backends to correctly attribute file changes to the session that requested them. The current implementation likely associates changes based on "files modified while this session was active", which is unreliable in a concurrent multi-agent shared-worktree scenario.

A robust solution would require durable transaction IDs on all `WorkspaceEdit` objects applied during a chat session, and a corresponding revert mechanism that refuses to undo changes outside the originating transaction ID's scope.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.