Skip to content

Fix: Prevent Copilot agent from hanging during file editsFix: Prevent…#301151

Open
Adityakk9031 wants to merge 1 commit intomicrosoft:mainfrom
Adityakk9031:#301053
Open

Fix: Prevent Copilot agent from hanging during file editsFix: Prevent…#301151
Adityakk9031 wants to merge 1 commit intomicrosoft:mainfrom
Adityakk9031:#301053

Conversation

@Adityakk9031
Copy link

Fixes #301053

Description

This PR fixes an issue where the Copilot agent gets stuck in an infinite "Loading" hang state when attempting to edit a file.

The root cause was traced to a race condition in src/vs/workbench/contrib/chat/common/tools/builtinTools/editFileTool.ts where the autorun observer strictly required the isCurrentlyBeingModifiedBy flag on the ModifiedFileEntry to dynamically toggle to true and then back to false.

If the chatCodeMapperService processes the edits fast enough (or realistically, synchronously), or if the file content matches the proposed edits perfectly such that no modifications are queued, the flag is already false when the observer attaches. Because the strict wasFileBeingModified state was never met, the agent waited on an unresolvable promise forever.

This PR simplifies the observation logic to check if isCurrentlyBeingModifiedBy evaluates to false. It correctly assumes the modifications have finished applying (or did not need to run), allowing the EditTool promise to resolve elegantly and unblock the Copilot agent's workflow.

Changes Made

  • [editFileTool.ts]: Replaced the wasFileBeingModified tracking boolean inside the autorun promise block. The promise will now cleanly resolve if the file is not currently being modified (i.e. !currentFile.isCurrentlyBeingModifiedBy.read(r)).
  • Assigned strict generics Promise<void> and invoked resolve() correctly without boolean arguments.

Testing

  • Tested manually by triggering File Edits with the chat agent. Fast edits no longer freeze the agent inline.

… Copilot agent from hanging during file editsFix: Prevent Copilot agent from hanging during file editsFix: Prevent Copilot agent from hanging during file edits
@Adityakk9031
Copy link
Author

@microsoft-github-policy-service agree

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.

Agent stopped editting code in VS Code

2 participants