Fix: Prevent Copilot agent from hanging during file editsFix: Prevent…#301151
Open
Adityakk9031 wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix: Prevent Copilot agent from hanging during file editsFix: Prevent…#301151Adityakk9031 wants to merge 1 commit intomicrosoft:mainfrom
Adityakk9031 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
… Copilot agent from hanging during file editsFix: Prevent Copilot agent from hanging during file editsFix: Prevent Copilot agent from hanging during file edits
Author
|
@microsoft-github-policy-service agree |
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.
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
autorunobserver strictly required theisCurrentlyBeingModifiedByflag on the ModifiedFileEntry to dynamically toggle totrueand then back tofalse.If the
chatCodeMapperServiceprocesses 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 alreadyfalsewhen the observer attaches. Because the strictwasFileBeingModifiedstate was never met, the agent waited on an unresolvable promise forever.This PR simplifies the observation logic to check if
isCurrentlyBeingModifiedByevaluates tofalse. 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
wasFileBeingModifiedtracking boolean inside theautorunpromise block. The promise will now cleanly resolve if the file is not currently being modified (i.e.!currentFile.isCurrentlyBeingModifiedBy.read(r)).Promise<void>and invoked resolve() correctly without boolean arguments.Testing